Ruby on rails ';作为可注释的,带有线程';不保存评论
这是我的表格:Ruby on rails ';作为可注释的,带有线程';不保存评论,ruby-on-rails,ruby-on-rails-3,acts-as-commentable,Ruby On Rails,Ruby On Rails 3,Acts As Commentable,这是我的表格: <%=form_for [current_user, @tattoo, @comment], :remote => false, :html =>{:multipart => true} do |f|%> <ol> <li> <%=f.hidden_field :commentable_id, :value=> @tattoo.id %><br <%=f.lab
<%=form_for [current_user, @tattoo, @comment], :remote => false, :html =>{:multipart => true} do |f|%>
<ol>
<li>
<%=f.hidden_field :commentable_id, :value=> @tattoo.id %><br
<%=f.label :body%>
<%=f.text_area :body, :style=>"width:320;height:80px"%>
</li>
<li class="submit">
<%=f.submit "Add comment"%>
</li>
</ol>
<%end%>
我的路线是:
resources :users do
resources :tattoos
resources :comments
end
表格有效,我可以提交,控制台显示:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"t6/o2soSU9fAKW/3Sro2kSbyc5WBrs/F0xMIKbwAKaU=", "comment"=>{"commentable_id"=>"4", "body"=>"sdfsdf"}, "commit"=>"Add comment", "user_id"=>"1", "tattoo_id"=>"4"
但是什么都没做,我做错了什么?你没有打电话给
@comment.save
!天哪,我是个白痴。问题解决
Parameters: {"utf8"=>"✓", "authenticity_token"=>"t6/o2soSU9fAKW/3Sro2kSbyc5WBrs/F0xMIKbwAKaU=", "comment"=>{"commentable_id"=>"4", "body"=>"sdfsdf"}, "commit"=>"Add comment", "user_id"=>"1", "tattoo_id"=>"4"