This project is archived and is in readonly mode.
Rails.env.environment? extremely slow
-
Scott Windsor
- Assigned user set to Tarmo Tänav
Upon further investigation, the reason this is slow is that the Rails.env method call is requiring 'active_support/string_inquirer' in every single method call.
This was introduced in the following git commit... http://github.com/rails/rails/co...
This require isn't needed and can be taken out. I've attached a patch that includes both a fix and a unit test verifying the fix.
I'm also re-assigning this ticket to Tarmo since he introduced the bug.
-
Tarmo Tänav
The reason the require line was added was that the railties library does not load active_support and thus one could not call "Rails.env.production?" inside the initializer block in environment.rb.
If you can make that work without using the require line (perhaps by making railties load the inquirer separately), then I'm sure the patch will be accepted.
-
Pratik
- State changed from new to resolved
- Tag changed from 2.1.1, performance to 2.1.1, performance
-
Stephen Touset
The fix to this seems to have been reverted, and the file is no longer being required at all in initializer.rb. This causes things like "Rails.env.test?" to fail in config/environment.rb.
