'acts_as_commentable_with_threading'没有保存评论

时间:2011-08-21 23:49:01

标签: 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.label :body%>
      <%=f.text_area :body, :style=>"width:320;height:80px"%>
    </li>
    <li class="submit">
     <%=f.submit "Add comment"%>
    </li>
  </ol>

<%end%>

和我的comments_controller

 def create
  @tattoo = Tattoo.find(params[:comment][:commentable_id])
  @user = @tattoo.user_id
  @user_who_commented = current_user
  @comment = Comment.build_from(@tattoo, @user_who_commented.id, "Comment!" )
  redirect_to(user_tattoo_path(@user, @tattoo))
 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"

但是没有任何承诺,我做错了什么?

0 个答案:

没有答案