所以我有我的主页,landingpage.html.erb,我想在那里放置一个链接,该链接将指向另一个简单的页面,其中包含更多指向外部资源的链接。
着陆页.html.erb
<%= link_to "press", '/press', :method => :get %>
新闻.html.erb
<h1>Test!</h1>
(我也做了一个部分,测试它是否会被显示。它同样是 press.html.erb 但是 _press.html.erb)
Controller
def press
end
我不断收到错误:
Routing Error
No route matches [GET] "/press"
我哪里错了?谢谢。
最佳答案
您还需要将路由添加到您的config/routes.rb
。这取决于您如何定义其他路由,但基本定义如下所示:
get '/press', to: 'controller_name#press'
阅读更多关于 Routing in the Rails Guides 的信息.
关于html - 如何从 html erb 文件链接到 rails 中的另一个 View (来自同一 Controller )?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23574244/