« May 2006 | Main | July 2006 »

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:
  • 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.
Which is better? It depends on what you need. I often have logic in my models that is kicked off on instantiation -- in this case, the the instantiation script is crucial, because the model will be forced to to whatever the model is meant to do upon instantiation.

Continue reading "Use models to instantiate your Rails fixtures" »

Rails Day '06 here we come

Jun 06 by Andre in Misc » , Ruby on Rails »
So I'm all signed up for Rails Day 2006. The goal: with a small team (<=3 peeps), develop the coolest possible Rails app in 24 hrs. Yep 24 hrs. If Jack Bauer coded Rails, this would be his kind of thing. Come to think if it, it would be great to have Chloe O'Brian on our team.

My co-conspiritor for this effort is Josh Susser from has_many :through. We're not ready to talk about details of the project, but definitely expect something cool and useful!

update
: Chris Wanstrath is a part of our team as well. I'm really looking forward to this!

Beyond RD'06, I've had a lot going on over the last few weeks. Last month I sold some commercial development/consulting on Rails -- a hosted lead management system for small business. Also, I'm getting ready to launch an experiment in Web 2.0-style collaboration (codename Thoth) -- it will go up in the next few days.