Using the rails rake toolset

//Using the rails rake toolset

Using the rails rake toolset

By | 2016-01-20T03:17:59+01:00 April 13th, 2009|Software development|0 Comments

Programming is like art, its a creation. I create, but I’m not always sure what I’m creating! I start with an idea, sketch it out on a piece of A5 (normally a few words, pictures and reminders) and then go for it. Some might call that PPP (piss poor planning).

In rails terms, that means I start scaffolding, create controllers and models, the core ones anyway. Then I start thinking about what database fields I need and end up adding to the nnn_create_<table>.rb migrations and re-running rake commands as I haven’t really done any ‘proper’ hard core coding yet to get to the basic database structure needed.

The rake tools are excellent in giving me a helping hand and if using Aptana I don’t even have to leave the dev environment. Nice for a lazy person like me. Here’s what I do – the long hand version:

  1. rake db:drop  (as I only need to drop the current RAILS_ENV which is development)
  2. rake db:create
  3. Delete schema.rb in /workspace/<projectname>db
  4. rake db:migrate

A clean database schema and a new shiny looking schema.rb is automatically created for me. Now I can go test some more and tweak as needed. Of course, I don’t advise this once you are in full coding swing just perhaps maybe at the very start, or plan better!

Leave A Comment