Monday, March 2, 2009

DB2 on Rails

I'm starting again with the IBM_DB adapter gem, available at: http://rubyforge.org/projects/rubyibm/

  • gem install ibm_db
  • rails newapp
  • cd newapp
  • ruby script/console
  • >> gem 'ibm_db'
  • ruby script/generate model person
  • in the file db/migrate/*_create_person.rb, define the following:
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.column :firstname, :string
t.column :lastname, :string
t.column :phone, :stringgg
end
end

def self.down
drop_table :people
end
end

  • rake db:migrate

No comments: