Jonathan
Jonathan

Reputation: 608

Default root url and display the controller action rather than "/" in rails 3

Is there a way to set the default root routes in rails to be one of my controller action and showing in the url rather than the root "/" ? Say I have a "Computer" controller with a "index" action.

When my user login to my application, I want the url to be

http://localhost:3000/computer/index rather than http://localhost:3000/

root :to => "computers#index"

does the latter one, how can I make the default root url to be something like the prior one ?

UPDATE: a better way would be

root :to => redirect(/path)

Upvotes: 2

Views: 1934

Answers (1)

dnch
dnch

Reputation: 9605

The simplest way would be to change which URL your users get re-directed to after they successfully log in.

You could also add a forced re-direct in your controller:

# routes.rb
root :to => "computers#force_redirect"

# computers_controller.rb
def force_redirect
  redirect_to '/computers/index'
end

Upvotes: 2

Related Questions