Possible Duplicate:
Best way to use html5 data attributes with rails content_tag helper?
How can I use html5 data-*
attrubute in my link_to helper (Rails)
The API says that I have to use this format link_to(body, url, html_options = {})
but I have an error when I put it in html_options
Ex:
link_to "whatever", @whatever_path, { class: 'my_class', data-tooltip: 'what I want' }
Just pass them in... Rails has a default
:data
hashOne gotcha - you must surround symbols with quotes if they include a dash:
Update: In Rails 4, underscores are automatically converted to dashes, so you can do this:
Alternatively you can just write it directly:
Update 2: As pointed out in the comments, Ruby 1.9+ allows this syntax, which some believe is cleaner:
Add a
data-
attribute by doing the following: