我目前正在为我的申请制作一个具有以下路线的应用程序。
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
_navigation
部分文件,如下所示
<% 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 %> |
.......
现在,当我导航到&#34;问题时,添加新问题&#34;我没有得到&#34; home&#34;与链接。
解决此问题的任何建议?
答案 0 :(得分:1)
我认为你应该尝试一下:
<% if controller_name == "pages" %>
<bold>Home</bold> |
<% else %>
<%= link_to "Home", home_path %> |
<% end %>