<% form_for [commentable, Comment.new], :action => 'create', :remote => false do |f|%>
<%=f.hidden_field :commentable_id, :value=> commentable.id %><br/>
<%=f.hidden_field :parent_id, :value=>1 %><br/>
def create(commentable)
@commentable = commentable.find(params[:comment][:commentable_id])
如何我可以通過commentable類型在我for_for創建操作? 謝謝。
我想你需要重塑你的問題,如果你想進一步的協助,你可以分享更多關於你的代碼? – tommasop
在你的控制器中,嘗試'@commentable = Commentable.create(params [:comment] [:commentable_id])' –