Change html form id generated by form_for rails 3.1

前端 未结 3 975
心在旅途
心在旅途 2021-02-06 21:41

I have this form_for:

<%= form_for [post, Comment.new,], :remote => true do |f| %>
<%= f.text_area :content, :cols =>10, :rows => 1%>
<%          


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-06 22:21

    Adding on to what miked said, the easiest way to make unique form id's for the posts would be to use the post's id numbers in the id attribute, like so:

    <%= form_for [post, Comment.new,], :remote => true, :html => { :id => "new_comment_on_#{post.id}" } do |f| %>
    

提交回复
热议问题