This project is archived and is in readonly mode.

#819 ✓wontfix
ronin-28893 (at lighthouseapp)

ENV['RAILS_ENV] modification not taken into account by database raske tasks

Reported by ronin-28893 (at lighthouseapp) | August 13th, 2008 @ 04:54 PM | in 2.x

The switching environment (for example from 'development' to 'test') defined in a rake task is not taken into account by database rake tasks (databases.rake)

here is an example that shows the bug :


desc 'Buggy environment switch'
task :do_sth_in_test_env do
  # we are currently in dev env and
  # we have an empty test database
  ENV['RAILS_ENV'] = 'test'
  Rake::Task['db:fixtures:load'].invoke
  # result : no fixture in the test database
end

The bug comes fom the fact that, in many tasks defined in databases.rake, the constant RAILS_ENV is used directly instead of using ENV['RAILS_ENV']

You'll find in attachment a patch that corrects this bug

Comments and changes to this ticket

  • ronin-28893 (at lighthouseapp)

    ronin-28893 (at lighthouseapp) August 13th, 2008 @ 04:26 PM

    I reformat the example code :

    
    desc 'Buggy environment switch'
    task :do_sth_in_test_env do
      # we are currently in dev env and
      # we have an empty test database
      ENV['RAILS_ENV'] = 'test'
      Rake::Task['db:fixtures:load'].invoke
      # result : no fixture in the test database
    end
    
  • josh

    josh November 22nd, 2008 @ 07:29 PM

    • State changed from “new” to “wontfix”

    I don't think we should revert back to relooking up the ENV info everything. a performance and design issue.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages