0
是正確的,但問題仍然存在,我做的所有代碼到所有你看到的路由錯誤的Rails,不undertand
Routing Error
No route matches {:controller=>"posts", :user_id=>#<Post id: 1, title: "sa", content: "sasa", created_at: "2013-01-06 00:25:03", updated_at: "2013-01-06 00:25:03", image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil, user_id: 1>, :action=>"edit"}
Try running rake routes for more information on available routes.
我的路線是:
get "painel/index"
resources :posts
resources :user do
resources :posts,:comments
end
和我的模型是:
user.rb
attr_accessible :email, :password, :password_confirmation,:username
has_many :posts
has_many :comments
post.rb
attr_accessible :content, :title ,:image
has_many :comments
belongs_to :user
它看起來像b/n:posts資源和:user /:posts資源不匹配,而不是將控制器設置爲'posts',你可能希望它是'user/posts'。 .. 請告訴我們你是如何調用該路線(即link_to呼叫...)。 –