Answer the question
In order to leave comments, you need to log in
Rails add class="active" when url is within the same controller (:resources)?
This helper is walking on stack overflow.
def current_link_to label, path
link_to label, path, class: (current_page?(path) ? "active" : nil)
end
Answer the question
In order to leave comments, you need to log in
Mistake:
No route matches {:action=>"index", :controller=>"welcome"}
Extracted source (around line #13):
10
%h1.logo Флайда
%ul.menu
%li
= current_link_to 'Главная', root_path
resources :services
root :to => 'welcome#hi'
get 'contacts' => 'welcome#contacts'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question