I have nested routes in my routes.rb
resources :companies do
resources :employees
resources :accounts
end
In top menu I want to show a certain link when user is in company's controller or in nested controllers (employees, accounts). So, I want a simple «if statement» for it.
I've tried several approaches.
<%= if params[:company_id].present? %> # doesn't work in company views
# certain link
<% end %>
<%= if current_page?(controller: 'companies') %> # doesn't work in nested controllers' views
# certain link
<% end %>
Of course, it is possible to use both of them with or
, but I think it can be a better way for this.
Thanks!