Rails: 如何link 到静态页面

Rails: How to link to static pages

我想做的是 link 到 Rails 中的静态页面。

页面创建于sample.com/path1/path2/page.html.erb

我怎样才能link到page.html.erb

在你的 routes.rb 你应该有类似

的东西
get '/page', to: 'path#page', as: :page

其中 path 是页面文件所在的文件夹

例如

get '/page', to: 'layout#page', as: :page

那么你将 link 和

<li><%= link_to "page", page_path %>