useful rails command-line tasks

Use mysql as the database rather than sqlite:

>rails newproj -d mysql

Create migration with new field to existing table:

>script/generate add_fieldname_to_tablename fieldname:fieldtype

Generate a scaffold for an existing class and table

>script/generate scaffold ClassName fieldname:fieldtype --skip-migration

See routes:

>rake routes

See all rake tasks:

>rake -T

Migrate specific database:

>rake db:migrate RAILS_ENV=production

Migrate database to specific version:

>rake db:migrate VERSION=2

Migrate to second-to-last version:

>rake db:rollback

Leave a Reply