Revision 9a9ec5b1
Added by Daniel Lobato Garcia over 8 years ago
app/models/user_role.rb | ||
---|---|---|
validates :role_id, :presence => true
|
||
validates :owner_id, :presence => true, :uniqueness => {:scope => [:role_id, :owner_type],
|
||
:message => N_("has this role already")}
|
||
|
||
delegate :expire_topbar_cache, :to => :owner
|
||
|
||
def user_role?
|
||
self.owner_type == 'User'
|
||
end
|
||
... | ... | |
after_save :cache_user_roles!
|
||
before_destroy :remove_cache!
|
||
|
||
def expire_topbar_cache(sweeper)
|
||
owner.expire_topbar_cache(sweeper)
|
||
end
|
||
|
||
private
|
||
|
||
def remove_cache!
|
Also available in: Unified diff
Refs #3809 - Enable Rails delegate cop