title: How to add a custom attribute to the HTML output of rails link_to
body: <p>With rails version 2.3.8 I'm trying to get HTML output like:</p>
  
  <pre><code>    &lt;a href="/product/list" data-role="button"&gt;Product list&lt;/a&gt;
  </code></pre>
  
  <p>So an A tag with a custom attribute "data-role". (The reason I want the "data-role" attribute is that I'm working with <a href="http://jquerymobile.com/" rel="noreferrer">JQuery Mobile</a> which picks up on this attribute and does its magic) So I was trying to do this  </p>
  
  <pre><code>    &lt;%= link_to "product list", :controller =&gt; "product", :action =&gt; "list", "data-role" =&gt; "button" %&gt;
  </code></pre>
  
  <p>Judging by <a href="http://fuelyourcoding.com/getting-started-with-jquery-mobile-rails-3/" rel="noreferrer">this tutorial</a> perhaps this would work in rails 3, but in rails 2.3.8 it interprets it by generating a data-role=button parameter on the link URL.</p>
  
  <p>One way I can get the desired HTML output is to use url_for instead:</p>
  
  <pre><code>    &lt;a href="&lt;%=url_for :controller =&gt;"product", :action =&gt; "list" %&gt;" data-role="button"&gt;Product list&lt;/a&gt; 
  </code></pre>
  
  <p>A bit long and ugly. Is there a way to make link_to output custom attributes in the A tag (?)</p>