Ruby on rails 3 在rails中使用成员
大家好,我是rails 3的新手,我有一个应用程序,我想把一个想法和一条评论联系起来 当我显示一个想法时,我会在视图的底部显示一个表单,为这个想法添加新的注释,当单击保存注释时,我必须传递想法id,我会创建我的模型注释Ruby on rails 3 在rails中使用成员,ruby-on-rails-3,Ruby On Rails 3,大家好,我是rails 3的新手,我有一个应用程序,我想把一个想法和一条评论联系起来 当我显示一个想法时,我会在视图的底部显示一个表单,为这个想法添加新的注释,当单击保存注释时,我必须传递想法id,我会创建我的模型注释 belongs_to :user belongs_to :idea attr_accessible :description, :likes, :name, :user_id, :idea_id 从展示创意a的角度来看 = render :partial =>
belongs_to :user
belongs_to :idea
attr_accessible :description, :likes, :name, :user_id, :idea_id
从展示创意a的角度来看
= render :partial => "comments/index", :collection => @idea.comments
= render :partial => "comments/form", :locals => {:comment=> @comment}
resources :ideas do
member do
resources :comments
end
end
在注释的_形式中,我包含idea以获取要保存的idea id
= form_for [@idea, @comment] do |f|
在我的路由器里我放了这个
= render :partial => "comments/index", :collection => @idea.comments
= render :partial => "comments/form", :locals => {:comment=> @comment}
resources :ideas do
member do
resources :comments
end
end
现在我得到了这个错误
undefined method `idea_comments_path'
任何想法,任何人都知道一个更好地解释如何在rails中使用成员的文档 嵌套资源不需要
成员
:
resources :ideas do
resources :comments
end