Rails environments are wonderful. But they can be a bit confusing do to some inconsistency in terms of which environments are affected when you run certain rake tasks.
After some digging I think I figured it out.
db:create – affects both development and test environments
db:drop – only affected development (though this has changed)
db:migration – runs against your current environment (usually development)
hence the need for
db:test:prepare (to apply migrations against your test environment)
So in summary, you always need to specify the environment your rake tasks run against
$ rake foo RAILS_ENV=test
With the exception of db:create and db:drop above.
Links that helped:
https://github.com/rails/rails/pull/2419
http://railsforum.com/viewtopic.php?id=6648
http://jasonseifer.com/2010/04/06/rake-tutorial
Filed under: rails Tagged: rails, RoR, rubyonrails
