Commit 84e3a2a00b1e4034d8e7ec8129b20cf110f951a1
Committed by
Daniela Feitosa
1 parent
57d2dac6
Exists in
master
and in
28 other branches
ActionItem1080: fixing association in migration
Showing
1 changed file
with
2 additions
and
2 deletions
Show diff stats
db/migrate/069_add_enviroment_id_to_role.rb
@@ -6,7 +6,7 @@ class RoleWithEnvironment < ActiveRecord::Base | @@ -6,7 +6,7 @@ class RoleWithEnvironment < ActiveRecord::Base | ||
6 | end | 6 | end |
7 | class RoleAssignment < ActiveRecord::Base | 7 | class RoleAssignment < ActiveRecord::Base |
8 | belongs_to :accessor, :polymorphic => true | 8 | belongs_to :accessor, :polymorphic => true |
9 | - belongs_to :target, :polymorphic => true | 9 | + belongs_to :resource, :polymorphic => true |
10 | end | 10 | end |
11 | 11 | ||
12 | class AddEnviromentIdToRole < ActiveRecord::Migration | 12 | class AddEnviromentIdToRole < ActiveRecord::Migration |
@@ -19,7 +19,7 @@ class AddEnviromentIdToRole < ActiveRecord::Migration | @@ -19,7 +19,7 @@ class AddEnviromentIdToRole < ActiveRecord::Migration | ||
19 | re = RoleWithEnvironment.new(role.attributes) | 19 | re = RoleWithEnvironment.new(role.attributes) |
20 | re.environment = env | 20 | re.environment = env |
21 | re.save | 21 | re.save |
22 | - RoleAssignment.find_all_by_role_id(role.id).select{|ra| (ra.target.kind_of?(Profile) ? ra.target.environment_id : ra.target.id) == env.id }.each do |ra| | 22 | + RoleAssignment.find_all_by_role_id(role.id).select{|ra| (ra.resource.kind_of?(Profile) ? ra.resource.environment_id : ra.resource.id) == env.id }.each do |ra| |
23 | ra.role_id = re.id | 23 | ra.role_id = re.id |
24 | ra.save | 24 | ra.save |
25 | end | 25 | end |