Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何正确链接到静态页面?_Ruby On Rails_Static_Routes - Fatal编程技术网

Ruby on rails 如何正确链接到静态页面?

Ruby on rails 如何正确链接到静态页面?,ruby-on-rails,static,routes,Ruby On Rails,Static,Routes,我遵循railscast使用页面模型创建和显示静态页面,我的代码如下所示: match ':permalink', :controller => 'pages', :action => 'show', :as => 'my_page' <%= link_to 'About Us', my_page_path('about') %> 页面模型 具有名称、永久链接和描述字段 路线: _footer.html.erb 转到/localhost:3000/about

我遵循railscast使用页面模型创建和显示静态页面,我的代码如下所示:

match ':permalink', :controller => 'pages', :action => 'show', :as => 'my_page'
<%= link_to 'About Us', my_page_path('about') %>
页面模型

具有名称、永久链接和描述字段

路线:

_footer.html.erb


转到/localhost:3000/about会正确显示“关于”页面,但页脚中的链接希望指向/localhost:3000/.about并实际链接到“注册新用户”页面

如何获取指向/关于并显示页面的链接


谢谢你的帮助,非常感谢

root_路径将始终将您带到users#new,因为这是您在routes.rb文件中指定的。您可以使用:as键命名最后一条路线,如下所示:

match ':permalink', :controller => 'pages', :action => 'show', :as => 'my_page'
<%= link_to 'About Us', my_page_path('about') %>
那么在你看来,你应该可以做这样的事情:

match ':permalink', :controller => 'pages', :action => 'show', :as => 'my_page'
<%= link_to 'About Us', my_page_path('about') %>

您是否尝试过“about”)%%>?@bor1s,感谢您的浏览,它链接回“欢迎登上rails页面”,并显示一个url“/localhost:3000/?permalink=about”