Removed acts_as_paranoid. Implemented own version.
This commit is contained in:
parent
8bafb3f4b2
commit
07581b7ecf
25 changed files with 93 additions and 57 deletions
|
|
@ -1,13 +1,15 @@
|
|||
# Groups organize the User.
|
||||
# A Member gets the roles from the Group
|
||||
class Group < ActiveRecord::Base
|
||||
has_many :memberships, :dependent => :destroy
|
||||
has_many :memberships
|
||||
has_many :users, :through => :memberships
|
||||
|
||||
validates :name, :presence => true, :length => {:in => 1..25}
|
||||
|
||||
attr_reader :user_tokens
|
||||
|
||||
|
||||
scope :undeleted, -> { where(deleted_at: nil) }
|
||||
|
||||
# Returns true if the given user if is an member of this group.
|
||||
def member?(user)
|
||||
memberships.find_by_user_id(user.id)
|
||||
|
|
@ -21,7 +23,19 @@ class Group < ActiveRecord::Base
|
|||
def user_tokens=(ids)
|
||||
self.user_ids = ids.split(",")
|
||||
end
|
||||
|
||||
|
||||
def deleted?
|
||||
deleted_at.present?
|
||||
end
|
||||
|
||||
def mark_as_deleted
|
||||
# TODO: Checks for participating in not closed orders
|
||||
transaction do
|
||||
memberships.destroy_all
|
||||
# TODO: What should happen to users?
|
||||
update_column :deleted_at, Time.now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue