venerdì 18 aprile 2008

The magic of Ruby and Rake.

Today is the first day, I ever used rake.

First of all, it's a bit different of other "make" system usally used, in which almost all task are defined within the file. Here I have *a huge* set of premade task, ready to work for me, without the hassole of writing a piece of rake file.

How do you get the list of available tasks ?
Easy. rake --task

Today my big concern was. How to populate an emtpy test/development database, with a lot of yml file and only one Rakefile, with no task inside.
After reading some infos i succeded in:

rake db:migrate
this will create and migrate you empty db, configured into database.yml, using your db/migrate ActiveRecord::Migration provided. Clearly the order is from the first, named 001_xxx.rb to the last.

After migrating all the db, you simply populate it with:
rake db:fixture:load
this works only if you have your "*.yml" files into test/fixtures, and I have been so lucky to have it. For each table you should have your .yml file that define and describe, in the Ruby way, each record.
Get more information about YAML fixture on

And today's task is accomplished. The homepage of my ruby application is ready.