开发者

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" controlle开发者_开发百科r 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)


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜