Rails 3 - When loading a partial how to Combine a String (comment_) with a variable
I have the following:
commentable.id =3131
In the partial:
&开发者_运维问答lt;%=f.text_area :content, :id=> 'comment_content_' commentable.id %>
I want it to make:
<textarea id="comment_content_3131" />
How do I combine the string with a variable in the partial? Thanks
Just concatenate the two strings:
<%=f.text_area :content, :id=> ('comment_content_' + commentable.id.to_s) %>
As you would substitute any other string. :)
<%= f.text_area :content, :id=> "comment_content_#{commentable.id}" %>
精彩评论