开发者

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

开发者 https://www.devze.com 2023-03-20 15:45 出处:网络
I have a <% @user.comments.each do |comment| %> and inside it is <%= form_for [????, Subcomment.new],:remote => true do |form| %>

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

精彩评论

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