How can I generate a unique dom id for a html tag from model
I am having an index view with several rows for items which have multiple attributes. I would like to update the content of an items attribute with ajax, therefore I need a unique dom id. Is there a helper method available? What I am doing right now is: <span id="<%= item.id.to_s + "_on_storage"%>"> Best, Phil You can use dom_id(item) Which is an ActiveRecord method for generating DOM IDs. A good practice as well is to use HTML5 data attributes: <span data-item-id="<%= item.id %>"> 来源: https://stackoverflow.com/questions/11817398/how-can-i-generate-a-unique-dom-id-for-a-html-tag-from-model