Loading Fixtures Earlier

I have a few ActiveRecord subclasses that reassign their default scope
upon instantiation based on some criteria (i.e. subclasses of the AR
model Person will change their default scope according to rows found
in the roles table). This works find during development, but during
testing this fails because the fixtures (which contain the roles
items) are not loaded until after the models are causing an exception
to be raised.

Is there any way to have fixtures loaded earlier on in the testing
process, or is there some proper Rails-provided way to seed the test
database?

Thanks,
—matt

Is there any way to have fixtures loaded earlier on in the testing
process, or is there some proper Rails-provided way to seed the test
database?

 Yes. From 2.3.4 onwards there is db/seeds.rb file .You can write 

put data there. For more information please watch this Railscast

http://railscasts.com/episodes/179-seed-data

Sijo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs