Add and inherit from ApplicationRecord to match Rails 5.0 style
This commit is contained in:
parent
8c6d48da86
commit
abe847c0ee
34 changed files with 56 additions and 66 deletions
|
|
@ -1,16 +1,15 @@
|
|||
class Membership < ActiveRecord::Base
|
||||
|
||||
class Membership < ApplicationRecord
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :group
|
||||
|
||||
before_destroy :check_last_admin
|
||||
|
||||
|
||||
|
||||
protected
|
||||
|
||||
# check if this is the last admin-membership and deny
|
||||
def check_last_admin
|
||||
raise I18n.t('model.membership.no_admin_delete') if self.group.role_admin? && self.group.memberships.size == 1 && Group.where(role_admin: true).count == 1
|
||||
raise I18n.t('model.membership.no_admin_delete') if self.group.role_admin? && self.group.memberships.size == 1 && Group.where(role_admin: true).count == 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue