Monday, December 29, 2008

Starting SMS Application

Example: to create a table in database

1. create new rails project
rails sms -d mysql

enter the sms/ folder

2. edit the database config
vi db/config.yml

3. create the database using rake
rake db:create

4. create empty migration for contact_groups table
script/generate migration contact_groups

5. edit db/migrate/001_contacts_groups.rb

class ContactGroups < ActiveRecord::Migration
def self.up
create_table "contact_groups" do |t|
t.column "name", :string
t.column "description", :text
end
end

def self.down
drop_table "contact_groups"
end
end


6. create the table on database
rake db:migrate

7. start the server
script/server

8. view the application
http://localhost:3000


9.The screenshot

No comments:

Post a Comment