Rails link_to with inline styling Rails link_to with inline styling ruby-on-rails ruby-on-rails

Rails link_to with inline styling


How about

<%= link_to item.description, nil, {:style=>'color:#FFFFFF;', :class => "css_class"} %>

...or...

<%= link_to item.description, '#', {:style=>'color:#FFFFFF;', :class => "css_class"} %>


This should work with Rails 3

link_to item.description, :style=> 'color:#FFFFFF;', :class => 'css_class'

With the new syntax in rails 4, it becomes

link_to item.description, style: 'color:#FFFFFF;', class: 'css_class'


I want to update this topic, because in this time, the syntax is different.In rails 4+, the correct syntax is:

<%= link_to TEXT, URL, class: 'css_class', style: 'color:#FFFFFF' %>