I’m using jquery-mobile with Ruby On Rails.
I want to create a button link which implies to have data-role="button" appear in the generated HTML.
I’ve tried:
<%= link_to "Play", game_play_path, :data-role => "button" %>
But then, I get an error
undefined local variable or method `role' for #<#<Class:0x007fdc25668ee8>:0x007fdc25658610>
Is there a way to escape the dash using the :xxx notation or should I just use the "xxx" notation?
(I agree it’s a cosmetic question, but I want my code to be consistent and don’t like exceptions)
Use single quotes around the symbol name, with the colon prefix:
And here is a nice reference on symbols:
http://www.troubleshooters.com/codecorn/ruby/symbols.htm#_What_do_symbols_look_like
After
Ruby 1.9you can also do