开发者

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}" %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜