6
Apr

Rails: Cross Database development

   Posted by: Vivek Khokhar   in Ruby

Its a piece of cake developing applications that run on multitude of Database management solutions.
All you need to keep Database schema scripts handy. Here is how you do it using rails scripts:

> ruby script\generate migration Contact

This will create an empty file in db/migrate folder for contact table. You need to fill it now with the fields you want
for eg:

class Contact < ActiveRecord::Migration
def self.up
create_table :contacts do |table|
table.column :first_name, :string
table.column :last_name, :string
table.column :email, :string
table.column :phone, :string
table.column :address, :string
end
end
def self.down
end
end

Ok.. just found what I was looking for. Pretty detailed document for this: http://rubyonrails.org/api/classes/ActiveRecord/Migration.html

Now, apply the migration

> rake migrate

Now, generate model and controller for Contact

>  ruby script\generate scaffold Contact
This entry was posted on Thursday, April 6th, 2006 at 2:34 pm and is filed under Ruby. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply

You must be logged in to post a comment.