ere
ere

Reputation: 1779

rails active_link_to gem functioning on params

I'm using the Rails gem active_link_to for determining the active URL for menus. It works great on straight forward links such as '/controller/action' but how can I do it similarly for particular param?

Ie /controller/action?user=all

Or is there a better gem that can provide this?

https://github.com/twg/active_link_to

Upvotes: 2

Views: 559

Answers (1)

phillyslick
phillyslick

Reputation: 571

You could use the Regex functionality of the gem, depending on how your code is organized.

<%= active_link_to("Link Text", some_place_path, :active => /#{Regexp.escape(@param_value)}/, class: "blogYear") %>

You can execute code within a Regex with the above method if you are going to output the param or param value dynamically.

Upvotes: 1

Related Questions