Rails: Cross Database development

Posted by jeet
on Sunday, June 01

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

ruby script\generate scaffold Contact

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