0
我不斷收到郵政預期,得到字符串錯誤。如果有人可以提前幫助我。ActiveRecord :: AssociationTypeMismatch CommentsController#創建
<% form_for :comment, :url=>{:controller=>"comments", :action=>"create"} do |f|%>
<p>
<%= f.label :body, "New Comment"%><br />
<%= f.text_area :body %>
<%= f.hidden_field :post, :value=>@post.id %>
</p>
<p><%= f.submit "Add Comment"%></p>
<% end%>
def create
@comment = Comment.create(params[:comment])
if @comment.save
redirect_to(:controller=>"posts" ,:action=>'index')
else
redirect_to(:controller=>"posts" ,:action=>'show', :id=>"post.id")
end
end
這幫了我很多,謝謝! :) – okoronkwo 2010-11-23 12:10:58