Rails 根据 Rails 环境定义根 url
Rails define root url based on Rails Environment
有什么方法可以根据 Rails 环境定义不同的根 url。我想为开发和暂存环境设置 root :to => 'pages#index'
,为生产环境设置 root :to => 'beta_pages#index'
。
提前致谢。
是的,你可以做到。
在您的 routes.rb
文件中:
if Rails.env.development? || Rails.env.staging?
root :to => 'pages#index'
elsif Rails.env.production?
root :to => 'beta_pages#index'
end
有什么方法可以根据 Rails 环境定义不同的根 url。我想为开发和暂存环境设置 root :to => 'pages#index'
,为生产环境设置 root :to => 'beta_pages#index'
。
提前致谢。
是的,你可以做到。
在您的 routes.rb
文件中:
if Rails.env.development? || Rails.env.staging?
root :to => 'pages#index'
elsif Rails.env.production?
root :to => 'beta_pages#index'
end