Commands to set up project ( including model & controller)


#1

Create Project

rails project_name

change directory to ‘project_name’

project_name> ruby script/server

create 3 Databases

databasename_development
databasename_test
databasename_production

open database.yml in config folder and give the database details. I
think , you only have to give the password.

next, you have to create model

project_name> ruby script/generate model Model_name

edit /db.migrate/001_create_modelnames

add commands for creating table

for ex:-

def self.up
create_table :classifieds do |t|
t.column :title, :string
t.column :price, :float
t.column :location, :string
t.column :description, :text
t.column :email, :string
t.column :created_at, :timestamp
t.column :updated_at, :timestamp
end

then, execute this against database

projet_name> rake migrate

next, creating controller

project_name> ruby script/generate controller Controller_name