Rails - 使用/ Custom URL指定根路径:'/ dashboard'

时间:2013-04-01 17:57:35

标签: ruby-on-rails ruby ruby-on-rails-3 routes

如何将此根路径转到:'/ dashboard'而不只是http://example.com

root :to => 'dashboard#index', :constraints => lambda{|req| !req.session[:user_id].blank?}

1 个答案:

答案 0 :(得分:9)

您可以通过以下方式实现这一目标:

root :to => redirect('/dashboard')
match '/dashboard', :to => "dashboard#index",
  :constraints => lambda {|req| !req.session[:user_id].blank? }