Rails 嵌套静态路由
Rails nesting static routes
我有几个静态页面(关于、联系、帮助)映射到 routes.rb
文件中,如下所示:
get 'about', to: 'static#about', as: 'about'
get 'contact', to: 'static#contact', as: 'contact'
get 'help', to: 'static#help', as: 'help'
它们在部分布局中访问,_footer.html.erb
来自此代码:
<%= link_to "About", 'about_path', :class => '' %>
<%= link_to "Contact", 'contact_path', :class => '' %>
<%= link_to "Help", 'help_path', :class => '' %>
一切正常,直到我在像 /users/current/edit
这样的嵌套路由中单击页脚 links(我可以在其中编辑我的用户配置文件)。例如,当我点击页面底部的 ABOUT link 时,我希望直接转到 about_path
的 static#about 路由.
但是,我遇到了一个 ActionController 异常(开发中)和一个在生产中找不到的页面。它正在尝试映射到 /users/current/about_path
.
关于如何解决这个问题有什么想法吗?
查看 Thorin 的回答。删除路径方法调用周围的引号。
我有几个静态页面(关于、联系、帮助)映射到 routes.rb
文件中,如下所示:
get 'about', to: 'static#about', as: 'about'
get 'contact', to: 'static#contact', as: 'contact'
get 'help', to: 'static#help', as: 'help'
它们在部分布局中访问,_footer.html.erb
来自此代码:
<%= link_to "About", 'about_path', :class => '' %>
<%= link_to "Contact", 'contact_path', :class => '' %>
<%= link_to "Help", 'help_path', :class => '' %>
一切正常,直到我在像 /users/current/edit
这样的嵌套路由中单击页脚 links(我可以在其中编辑我的用户配置文件)。例如,当我点击页面底部的 ABOUT link 时,我希望直接转到 about_path
的 static#about 路由.
但是,我遇到了一个 ActionController 异常(开发中)和一个在生产中找不到的页面。它正在尝试映射到 /users/current/about_path
.
关于如何解决这个问题有什么想法吗?
查看 Thorin 的回答。删除路径方法调用周围的引号。