Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有什么方法可以根据 Rails 环境定义不同的根 url。我想root :to => 'pages#index'为开发和登台环境以及root :to => 'beta_pages#index'生产环境设置。
root :to => 'pages#index'
root :to => 'beta_pages#index'
提前致谢。
是的,你可以这么做。
在您的routes.rb文件中:
routes.rb
if Rails.env.development? || Rails.env.staging? root :to => 'pages#index' elsif Rails.env.production? root :to => 'beta_pages#index' end