Ruby on Rails v2 Notes

Dec 20, 2011 Published by Tony Primerano

Piles of notes at Ruby on Rails Notes but some of the stuff there is deprecated. Adding my notes/reminders for 2.0 here.

Application Creation

  • creating app is the same
    • rails yourapp
      • using mysql -> rails yourapp --database=mysql yourapp
    • create db
      • via rails
        • rake db:create RAILS_ENV='development'
      • with mysqladmin
        • mysqladmin -u root create yourapp_development
      • Sanity check with rake db:migrate


  • Dynamic Scaffolding is gone. No more magic.
  • Creating scaffolding for a product model
    • ruby script/generate scaffold site title:string description:text url:string
  • Update database
    • rake db:migrate
  • like rails 1.0 you can revert with
    • rake db:migrate VERSION=0
  • to destroy scaffolding run
    • ruby script/destroy scaffold site


  • generate migration creates a migration. Use add in name for updates and create for new tables
    • ruby script/generate migration add_time_to_site time:datetime
    • rake db:migrate
  • At this point your view is out of date. You can hand edit it or you can rerun the generate/scaffold command