Main image
23rd August
2008
written by simplelight

Rails Guides

Keeping Ruby on Rails up to date:

Installing gems on Dreamhost

Rails > 2.1 now with gem dependencies and here

ruby -v — check which version of ruby you have installed

rails -v — check which version of rails you have installed

gem list — check versions of all installed gems

sudo gem update — bulk update of all installed gems (some say this is a bad idea)

sudo gem update –system (updates rubygems, note use of double dash)

sudo gem uninstall <gem_name> — uninstall a specific gem

sudo gem install <gem_name> — install a specific gem

sudo gem cleanup — remove old versions of gems

sudo gem install -v=2.0.2 rails — install a specific version of Rails (to stay in synch with Dreamhost)

Rmagick

Installing Rmagick

  1. sudo apt-get update
  2. sudo apt-get install imagemagick
  3. Then, install the imagemagick9 dev library:
    sudo apt-get install libmagick9-dev
  4. Last, install the RMagick gem:
    sudo gem install rmagick

Rails Migrations

Useful cheat sheet

Use rake db:schema:load if having trouble with Rails migrations and you have a working schema.

Use rake db:migrate VERSION=3 to roll back to version 3

Use rake db:migrate:reset — drop db, recreate it, and then run all migrations

rake db:rollback — go back one migration

rake db:migrate:redo — undo last migration and then redo it

rake db:sessions:clear — purge sessions from database

MySQL

To create a new MySQL DB on Dreamhost it is best to use the Dreamhost panel.

To create a database locally: mysqladmin -u root -p create <dbname>_development

mysql -u yourdblogin -p -hyourdbdomain.yourdomain.com yourdb

To load a table into a database:

mysql -u [username] -p[password] -hmysql.[domainname].com [database_name] < iso_country_list.sql

drop table sessions; — delete the sessions table

show tables; — show all tables for database

describe sessions; — show the sessions table

check table sessions; — check the sessions table for corruption and/or nonexistence

Gem Sources

Make sure to add GitHub: gem sources -a http://gems.github.com

Leave a Reply