Avoid environment detection on Rails.
Add this line to your application's Gemfile:
gem 'rails-env'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails-env
Instead of checking for the current environment like this:
if Rails.env.production?
# Do something with Rails.configuration
end
You can just use:
Rails.env.on(:production) do
config.assets.version = '1.0'
end
Looks dumb, but you don't have to use the long Rails.configuration
or assign it to a local variable. This is useful when you're extracting out things to initializers.
To match all environments, use :any
.
Rails.env.on(:any) do
config.assets.version = '1.0'
end
Previous versions used to yield the configuration; this is no longer true on 1.0+.
So, instead of using
Rails.env.on(:development) do |config|
config.assets.version = '1.0'
end
use
Rails.env.on(:development) do
config.assets.version = '1.0'
end
- Fork it ( https://github.com/fnando/rails-env/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request