If item_counter=213 then I want to set item_id to "item213". S开发者_开发技巧eems easy but:
<% item_id = "item" + item_counter %>
results in an error: can't convert Fixnum into String
<% item_id = "item" + item_counter.chr %>
outputs a strange character: item
   <% item_id = "item#item_counter" %>
is understood as item#item_counter
What is the correct way to concatenate an integer to a string in ERB (Ruby on rails 3)?
to_s is the method you're looking for:
<% item_id = "item" + item_counter.to_s %>
You can also use string interpolation:
<% item_id = "item#{item_counter}" %>
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论