Ganesh Kunwar
Ganesh Kunwar

Reputation: 2653

Rails define root url based on Rails Environment

Is there any way to define different root url based on Rails environment. I want to set root :to => 'pages#index' for development and staging environment and root :to => 'beta_pages#index' for production environment.

Thanks in advance.

Upvotes: 2

Views: 567

Answers (1)

K M Rakibul Islam
K M Rakibul Islam

Reputation: 34318

Yes, you can do that.

In your routes.rb file:

  if Rails.env.development? || Rails.env.staging?
    root :to => 'pages#index'
  elsif Rails.env.production?
    root :to => 'beta_pages#index'
  end

Upvotes: 4

Related Questions