Use models to instantiate your Rails fixtures
Jun 27 by
Andre in
How-to »
,
Ruby on Rails »
Following is a handy Rake script to import your fixtures (or a subset of your fixtures) through the associated model's constructor.
Say what? You import your fixtures with rake db:fixtures:load FIXTURES=neighborhoods,shops right? Yes, but there's a crucial difference:
Say what? You import your fixtures with rake db:fixtures:load FIXTURES=neighborhoods,shops right? Yes, but there's a crucial difference:
- The standard rake fixtures:load does a straight data load into the database -- your Rails Models are not involved. It's as if you did a series of INSERT INTOs through your MySQL command line.
- The instantiation script takes the fixture data, and invokes the associated model's constructor for each item.
Continue reading "Use models to instantiate your Rails fixtures" »