Reputation: 9522
I don't get along with the link_to
helper and similar stuff. I am trying to add a style to my link but I can't manage to do it, because according to the documentation the parameters are options and html_options, but then some parameters I am using are not even listed in the docs for link_to
so I don't know which are options and which html_options so I can't rearrage the hashes.
<%= link_to '+', :controller => 'shop', :action => 'add', :id => product, :remote => true %>
How should I rearrange the hashes to allow me to add :styles => 'color:red;.....'
?
Upvotes: 3
Views: 7459
Reputation: 654
This will work
<%= link_to '+', {:controller => 'shop', :action => 'add', :id => product, :remote => true}, :style=>'color: red;' %>
But is there any reason that you're not using the paths generated by the routes?
You can run rake routes
in your terminal to see paths available to you. Or if you know the controller you're looking for, something like rake routes | grep shop
will narrow down results for you.
Then you could do something like:
<%= link_to '+', add_shop_path(product), :style=>'color: red;' %>
Upvotes: 7