finally corrected that model thing.
This commit is contained in:
parent
5e26d72d91
commit
d1a6c512c4
|
@ -6,7 +6,13 @@ class Group < ActiveRecord::Base
|
|||
self.name = self.display_name.downcase.sub(/\s+/, '-')
|
||||
end
|
||||
|
||||
alias members group_members
|
||||
|
||||
def add_member(user)
|
||||
GroupMember.create! group: self, user: user
|
||||
end
|
||||
|
||||
def remove_member(user)
|
||||
GroupMember.where(group: self, user: user).first!.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class GroupMember < ActiveRecord::Base
|
||||
has_one :user
|
||||
has_one :group
|
||||
belongs_to :user
|
||||
belongs_to :group
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ class User < ActiveRecord::Base
|
|||
has_many :moderation_comments, dependent: :destroy
|
||||
has_many :moderation_votes, dependent: :destroy
|
||||
has_many :groups, dependent: :destroy
|
||||
has_many :group_memberships, class_name: "GroupMember", dependent: :destroy
|
||||
has_many :group_memberships, class_name: "GroupMember", foreign_key: 'user_id', dependent: :destroy
|
||||
|
||||
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
|
||||
WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i
|
||||
|
|
Loading…
Reference in New Issue