Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#819

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

Reported by ronin-28893 (at lighthouseapp) · August 13th, 2008 @ 04:54 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. ronin-28893 (at lighthouseapp)
    ronin-28893 (at lighthouseapp)

    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
    

    August 13th, 2008 @ 04:26 PM

  2. josh
    josh
    • 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.

    November 22nd, 2008 @ 07:29 PM