开发者

Environment-specific routing in Rails 3

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜