I have a text_area in a rails form helper:
<%= form_for(@comment, remote: true) do |f| %>
<%= f.text_area :content, placeholder: "Comment...", class: "common",
id: "comments-@post.id"%>
<span><%= hidden_field_tag :post_id, @post.id %></span>
<%= f.submit "Post Comment", class: "comment-submit btn btn-primary" %>
<% end %>
I would like to add an id number to the text_area's css id, so that once translated it is something like id="comments-1"
or id="comments-42"
In order to do this I need to use some embedded ruby as the id number is stored in the variable @post.id, however I'm getting an error because I'm putting embedded ruby: ( @post.id
) into more embedded ruby: ( <%= f.text_area ... %>
)
is there a way to get around this?
将id: "comments-@post.id"
替换为id: "comments-#{@post.id}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.