Commit 84e3a2a00b1e4034d8e7ec8129b20cf110f951a1

Authored by Moises Machado
Committed by Daniela Feitosa
1 parent 57d2dac6

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 6 end
7 7 class RoleAssignment < ActiveRecord::Base
8 8 belongs_to :accessor, :polymorphic => true
9   - belongs_to :target, :polymorphic => true
  9 + belongs_to :resource, :polymorphic => true
10 10 end
11 11  
12 12 class AddEnviromentIdToRole < ActiveRecord::Migration
... ... @@ -19,7 +19,7 @@ class AddEnviromentIdToRole &lt; ActiveRecord::Migration
19 19 re = RoleWithEnvironment.new(role.attributes)
20 20 re.environment = env
21 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 23 ra.role_id = re.id
24 24 ra.save
25 25 end
... ...