简体   繁体   中英

Routing to another html.erb file (Ruby on Rails)

I am learning how to login from Rails and I wanted to know one thing:

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

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:

get "/search/starter" => redirect("/app/views/usuarios/starter.html.erb")

You have to use the controller#action syntax to redirect. Example: if your controller is usuarios_controller.rb you should have inside an action named starter. Then in your routes.rb put this entry:

get "search/starter" =>  'usuarios#starter'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM