Fix for user and role relationship (from role and sub-role side)

This commit is contained in:
chris 2013-09-13 15:02:31 +08:00
parent 3595c59810
commit c1cbfddf4b
1 changed files with 20 additions and 0 deletions

View File

@ -328,6 +328,26 @@ namespace :migrate do
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