Dont use Rails.env before require rails/all

On rails 4.0+ , when calling Rails.env that will be memoized https://github.com/rails/rails/blob/4-0-stable/railties/lib/rails.rb#L56 , so if RAILS_ENV changes after that, for instance for tests https://github.com/rails/rails/commit/3ff263919c67588e4348da30cb92b860fe83cba5 that @_env ivar will have the wrong value.

Solution is not use Rails.env before requiring all rails
Merge pull request #807 from arthurnn/application_rb_change

Dont use Rails.env before require rails/all