Ceejay
Ceejay

Reputation: 7267

How can i add class to link_to in rails

Here i am trying to add the class for link_to element in rails.

here i have link_to element, i have added class for this element. but i am getting error..

here is what i have done

<%= link_to '+ Add New Product', :class => 'btn btn-primary', {action:"new_product_list_path"} %>

error i am getting is

syntax error, unexpected ')', expecting => ...tion:"new_product_list_path"} );@output_buffer.to_s ... ^ 
syntax error, unexpected keyword_ensure, expecting ')' 
syntax error, unexpected keyword_end, expecting ')'

how can i solve this?

Upvotes: 0

Views: 225

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118271

Here is the correct version:

<%= link_to '+ Add New Product', new_product_list_path, :class => 'btn btn-primary' %>

Upvotes: 2

Related Questions