Module: EnjuLibrary::LibraryItem::ClassMethods

Defined in:
lib/enju_library/item.rb

Instance Method Summary collapse

Instance Method Details

#enju_library_item_modelObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/enju_library/item.rb', line 8

def enju_library_item_model
  include InstanceMethods
  has_one :accept
  scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)}

  belongs_to :shelf, counter_cache: true, validate: true
  validates_associated :shelf

  searchable do
    string :library do
      shelf.library.name if shelf
    end
  end
end