Monday, December 29, 2008

Department hasMany Employees

Below is my employee migration class

class CreateEmployees < ActiveRecord::Migration
def self.up
create_table :employees do |t|
t.references :department
t.string :first_name
t.string :last_name
t.string :mobile_number
t.string :email
t.text :description

t.timestamps
end
end

def self.down
drop_table :employees
end
end

notice the "t.references :department" which is actually a reference to department model

No comments:

Post a Comment