Class: Elabs::Announcement

Inherits:
ApplicationRecord show all
Defined in:
app/models/elabs/announcement.rb

Instance Attribute Summary

Attributes inherited from ApplicationRecord

#changed_by

Class Method Summary collapse

Class Method Details

.for_user(user) ⇒ Object



18
19
20
21
22
23
24
# File 'app/models/elabs/announcement.rb', line 18

def self.for_user(user)
  return visible.where('target = ? OR target = ?', :global, :member) if user&.role == 'user'

  return visible.where('target = ? OR target = ? OR target = ?', :global, :member, :admin) if user&.role == 'admin'

  visible.where(target: :global)
end