Module: GroupedReader
- Defined in:
- lib/grouped_reader.rb
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/grouped_reader.rb', line 3 def self.included(base) base.class_eval { has_many :memberships has_many :groups, :through => :memberships accepts_nested_attributes_for :memberships include InstanceMethods alias_method_chain :activate!, :group alias_method_chain :send_functional_message, :group named_scope :in_groups, lambda { |groups| { :select => "readers.*", :joins => "INNER JOIN memberships as mm on mm.reader_id = readers.id", :conditions => ["mm.group_id IN (#{groups.map{'?'}.join(',')})", *groups.map{|g| g.is_a?(Group) ? g.id : g}], :group => "mm.reader_id" } } } end |