我觉得这应该很简单,但由于某种原因我无法弄清楚。当用户在显示页面上时,我只想将编辑和删除操作添加到导航栏。
我收到一个路由错误,说主页或新页面上不存在编辑操作,这是我的代码:
layouts/application.html.haml
.nav-collapse
%ul.nav.pull-right
%li= link_to "All Articles", root_path
%li= link_to "New Article", new_article_path
- if current_page?(@article)
%li= link_to 'Edit', edit_article_path
%li= link_to 'Delete', { :action => :destroy, :id => @article.id }, :method => :delete, :confirm => 'Are you sure?'