开发者

How can I pass a variable from a each do to a form_for inside it

I have a <% @user.comments.each do |comment| %>

and inside it is

<%= form_for [????, Subcomment.new],:remote => true do |form| %>

What can I use 开发者_开发知识库at ???? to ensure that the current @user.comment is passed to the controller?

If I use

<%= form_for [comment, Subcomment.new],:remote => true do |form| %>

I get

No route matches {:controller=>"subcomments", :comment_id=>#<Comment body: "Comments coming up twice", user_id: 2, commenter: "gleb", id: nil>}


If I got your question right, you need to create a hidden field comment_id

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜