Fix for user and role relationship (from role and sub-role side)
This commit is contained in:
parent
3595c59810
commit
c1cbfddf4b
|
@ -328,6 +328,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