[英]Routing to another html.erb file (Ruby on Rails)
I am learning how to login from Rails and I wanted to know one thing: 我正在学习如何从Rails登录,我想知道一件事:
I have several files which I want to show when a certain condition is met, in this case logging in will redirect me to another file called starter.html.erb 我有几个文件要在满足特定条件时显示,在这种情况下,登录会将我重定向到另一个名为starter.html.erb的文件。
I am trying to redirect it through both the controller and the routes files and I get the following error: 我试图通过控制器和路由文件将其重定向,但出现以下错误:
No route matches [GET] "/app/views/usuarios/starter.html.erb"
Can you please tell me what I'm doing wrong? 你能告诉我我做错了吗? Thanks!
谢谢!
Controller portion: 控制器部分:
redirect_to search_starter_path
routes.rb portion: route.rb部分:
get "/search/starter" => redirect("/app/views/usuarios/starter.html.erb")
You have to use the controller#action syntax to redirect. 您必须使用controller#action语法进行重定向。 Example: if your controller is usuarios_controller.rb you should have inside an action named starter.
示例:如果您的控制器是usuarios_controller.rb,则应在名为starter的动作中进行操作。 Then in your routes.rb put this entry:
然后在您的routes.rb中输入以下内容:
get "search/starter" => 'usuarios#starter'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.