【发布时间】:2010-10-22 15:14:41
【问题描述】:
我正在关注 Ryan Bate 的教程:http://railscasts.com/episodes/163-self-referential-association
但我的设置略有不同。
我正在制作自引用的 cmets,以便可以评论 cmets。
表单显示在视图中,但是当我提交时,我得到了这个:
Routing Error
No route matches "/conversations"
我的网址是这样写的:http://localhost:3000/conversations?convo_id=1
模型
#conversation.rb
belongs_to :comment
belongs_to :convo, :class_name => "Comment"
#comment.rb
belongs_to :post
has_many :conversations
has_many :convos, :through => :conversations
我的表格:
- for comment in @comments
.grid_7.post.alpha.omega
= comment.text
%br/
- form_for comment, :url => conversations_path(:convo_id => comment), :method => :post do |f|
= f.label 'Comment'
%br/
= f.text_area :text
%br/
= f.submit 'Submit'
我的对话控制器:
def create
@conversation = comment.conversations.build(:convo_id => params[:convo_id])
应用程序在此处创建失败,因为它永远不会到达create method 的重定向部分。
【问题讨论】:
标签: ruby-on-rails forms ruby-on-rails-3 model associations