Rails 4 - current_page? with query parameter -


i've method in application.rb

def current_page(path)   "active" if current_page?(path) end 

then in view, lets request_uri http://www.example.com/stories, can call

<%= link_to "all stories", stories_path, :class => "#{current_page(stories_path)}" %> 

but how if request_uri has http://www.example.com/stories?featured=true ? how call in view?

because current_page? method compare passed-in path doesn't have ? current url deleting query params.

for example, if you're @ http://www.example.com/stories?featured=true, , have current_page(stories_path), you'll still compare http://www.example.com/stories(stories_path) http://www.example.com/stories(your current url without featured=true).

i have idea, you'll have ? in end of normal url.you can change code <%= link_to "all stories", stories_path + '?', :class => "#{current_page(stories_path + "?")}" %>

i'll update if come better methods.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -