Home    | Software    | Articles    | Tips'n Tricks    | Contacts    | Support Us  
Home arrow Tips'n Tricks arrow Ruby on Rails arrow Add CSS class to link_to tag

Add CSS class to link_to tag

Just put controller related attributes between curly braces, the others will be rendered as html attributes. So, being the current controller "mycontroller", the following snippet:

<%= link_to "MyLink", {:action => "list"}, :class => "my_css_class"%>

will be rendered as:

< a href="/mycontroller/list" class="my_css_class">MyLink</a>
 
< Prev

  Articles RSS feed

Latest Articles
Latest Software
   
designed by allmambo.com