Julio Garcia
Julio Garcia

Reputation: 391

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")

Upvotes: 0

Views: 1788

Answers (1)

victormaidana
victormaidana

Reputation: 11

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'

Upvotes: 1

Related Questions