Fix for user and role relationship (from role and sub-role side)
This commit is contained in:
parent
b3366b48a1
commit
d5dc3ef793
|
@ -344,6 +344,26 @@ namespace :migrate do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Role.all.each do |role|
|
||||||
|
role.user_ids.uniq!
|
||||||
|
role.save
|
||||||
|
role.users.each do |user|
|
||||||
|
unless user.role_ids.include?(role.id)
|
||||||
|
user.role_ids << role.id
|
||||||
|
user.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
SubRole.all.each do |sub_role|
|
||||||
|
sub_role.user_ids.uniq!
|
||||||
|
sub_role.save
|
||||||
|
sub_role.users.each do |user|
|
||||||
|
unless user.sub_role_ids.include?(sub_role.id)
|
||||||
|
user.sub_role_ids << sub_role.id
|
||||||
|
user.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue