Skip to content

Commit

Permalink
added consultant skill many to many association
Browse files Browse the repository at this point in the history
  • Loading branch information
lfendy committed Nov 18, 2011
1 parent 519986c commit f612607
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/consultant.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Consultant < ActiveRecord::Base
has_and_belongs_to_many :skills
end
2 changes: 2 additions & 0 deletions app/models/consultant_skill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ConsultantSkill < ActiveRecord::Base
end
3 changes: 3 additions & 0 deletions app/models/skill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Skill < ActiveRecord::Base
has_and_belongs_to_many :consultants
end
9 changes: 9 additions & 0 deletions db/migrate/20111118054750_create_skills.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateSkills < ActiveRecord::Migration
def change
create_table :skills do |t|
t.string :name

t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20111118055057_create_consultants_skills.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateConsultantsSkills < ActiveRecord::Migration
def change
create_table :consultants_skills do |t|
t.integer :consultant_id
t.integer :skill_id

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoveSkillColumnFromConsultant < ActiveRecord::Migration
def up
remove_column :consultants, :skill
end

def down
add_column :consultants, :skill, :integer
end
end
16 changes: 14 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,26 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20111117033352) do
ActiveRecord::Schema.define(:version => 20111118055641) do

create_table "consultants", :force => true do |t|
t.string "name"
t.string "email"
t.string "role"
t.string "grade"
t.string "skill"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "consultants_skills", :force => true do |t|
t.integer "consultant_id"
t.integer "skill_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "skills", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
Expand Down
5 changes: 5 additions & 0 deletions spec/models/consultant_skill_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe ConsultantSkill do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/models/skill_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe Skill do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit f612607

Please sign in to comment.