Jadeler Amin wrote:> Is there a way to load the fixtures via another method other than what
> Im doing below?
>
> rake db:fixtures:load
> FIXTURES=companies,departments,employees,employee_details,phones,addresses
>
I too need loading fixtures in specific order due to foreign key constraints. So
I added a list to config/database.yml :
all_fixtures_load_order:
- :table1
- :table2
...
and wrote a rake task to load them:
namespace :db do
namespace :fixtures do
desc "Load all fixtures in particular order to satisfy FK
dependencies"
task :load_all => :environment do
require ''active_record/fixtures''
ActiveRecord::Base.establish_connection
Fixtures.create_fixtures(''test/fixtures'', FIXTURES
ActiveRecord::Base.configurations["all_fixtures_load_order"])
end unless :environment == ''production'' # don''t
load fixtures in production
end
end
Hope this helps.
Sava Chankov
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---