开发者

Environment-specific routing in Rails 3

开发者 https://www.devze.com 2023-03-18 13:24 出处:网络
I\'d like to create a scope in my routes.rb file to only route certain URLs when in the production environment. How do you use conditionals with Rails 3 routing? All开发者_开发百科 I need to do is res

I'd like to create a scope in my routes.rb file to only route certain URLs when in the production environment. How do you use conditionals with Rails 3 routing? All开发者_开发百科 I need to do is restrict those rules based on Rails.env.production? being true, but I'm not sure of the syntax.


routes.rb is Ruby file so this should work:

  if Rails.env.production?
    get "/bar" => 'welcome#index'
  else
    get "/foo" => 'welcome#index'
  end
0

精彩评论

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