Reputation: 2279
I am currently making an app having the following routes for my application.
refix Verb URI Pattern Controller#Action
root GET / pages#home
home GET /home(.:format) pages#home
problems GET /problems(.:format) problems#index
POST /problems(.:format) problems#create
new_problem GET /problems/new(.:format) problems#new
edit_problem GET /problems/:id/edit(.:format) problems#edit
problem GET /problems/:id(.:format) problems#show
PATCH /problems/:id(.:format) problems#update
PUT /problems/:id(.:format) problems#update
DELETE /problems/:id(.:format) problems#destroy
The _navigation
partial file as per follow
<% if !current_page?(home_path) and !current_page?(root_path) %>
<bold>Home</bold> |
<% else %>
<%= link_to "Home", home_path %> |
<% end %>
<% if !current_page?(problems_path) %>
<%= link_to "Problem list", problems_path %> |
<% else %>
<bold>Problem list</bold> |
<% end %>
<% if !current_page?(new_problem_path) %>
<%= link_to "Add new problem", new_problem_path %> |
.......
Now when I navigate to "problem, add new problem" I do not get the "home" with the link.
any advices to resolve this issue?
Upvotes: 0
Views: 37
Reputation: 2183
I think you should try it like :
<% if controller_name == "pages" %>
<bold>Home</bold> |
<% else %>
<%= link_to "Home", home_path %> |
<% end %>
Upvotes: 1