User#owned_groups is now respect group membership

This commit is contained in:
Dmitriy Zaporozhets 2013-06-21 22:38:43 +03:00
parent be26d2724b
commit 0273b79b92
1 changed files with 2 additions and 5 deletions

View File

@ -74,6 +74,8 @@ class User < ActiveRecord::Base
# Groups
has_many :own_groups, class_name: "Group", foreign_key: :owner_id
has_many :owned_groups, through: :users_groups, source: :group, conditions: { users_groups: { group_access: UsersGroup::OWNER } }
has_many :users_groups, dependent: :destroy
has_many :groups, through: :users_groups
@ -225,11 +227,6 @@ class User < ActiveRecord::Base
end
end
# Groups where user is an owner
def owned_groups
own_groups
end
# Groups user has access to
def authorized_groups
@authorized_groups ||= begin