MikaAK
MikaAK

Reputation: 2364

How can i add 2 class fields to link_to method

I'm trying to get this class to also use this custom method I have to check if the link is currently clicked on

=link_to 'Contact' , contact_path, :class => 'col-lg-4 col-md-4 col-sm-5 col-xs-4 ', :class => is_active?('contact)', :id => "contact"

Setting class 2 times has not worked anyone know how I can do this?

Upvotes: 0

Views: 59

Answers (2)

Jelle
Jelle

Reputation: 339

I thinks that xdazz is right that you can't set class twice. But you could add

is_active?('contact)'

to the classes :

:class => 'col-lg-4 col-md-4 col-sm-5 col-xs-4 #{is_active?(contact)}'

(assuming that is_active?(contact) results in a boolean value)

Upvotes: 1

xdazz
xdazz

Reputation: 160863

You can't set class twice.

:class => is_active? ? 'col-lg-4 col-md-4 col-sm-5 col-xs-4' : 'col-lg-4 col-md-4 col-sm-5 col-xs-4 contact'

Upvotes: 1

Related Questions