Sha256: 7c346cb14455d50d2e04c9c284f3e8cc1a177c1ffded0a7758f7489b50b1464e

Contents?: true

Size: 979 Bytes

Versions: 31

Compression:

Stored size: 979 Bytes

Contents

class Accept < ActiveRecord::Base
  attr_accessible :item_identifier, :librarian_id, :item_id
  default_scope :order => 'accepts.id DESC'
  belongs_to :basket
  belongs_to :item
  belongs_to :librarian, :class_name => 'User'

  validates_uniqueness_of :item_id, :message => I18n.t('accept.already_accepted')
  validates_presence_of :item_id, :message => I18n.t('accept.item_not_found')
  validates_presence_of :basket_id

  before_save :accept!, :on => :create

  attr_accessor :item_identifier

  paginates_per 10

  def accept!
    if defined?(EnjuCirculation)
      item.circulation_status = CirculationStatus.where(:name => 'Available On Shelf').first
    end
    item.save(:validate => false)
  end
end

# == Schema Information
#
# Table name: accepts
#
#  id           :integer          not null, primary key
#  basket_id    :integer
#  item_id      :integer
#  librarian_id :integer
#  created_at   :datetime         not null
#  updated_at   :datetime         not null
#

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
enju_library-0.1.0.pre32 app/models/accept.rb
enju_library-0.1.0.pre31 app/models/accept.rb
enju_library-0.1.0.pre30 app/models/accept.rb
enju_library-0.1.0.pre29 app/models/accept.rb
enju_library-0.1.0.pre28 app/models/accept.rb
enju_library-0.1.0.pre27 app/models/accept.rb
enju_library-0.1.0.pre26 app/models/accept.rb
enju_library-0.1.0.pre25 app/models/accept.rb
enju_library-0.1.0.pre24 app/models/accept.rb
enju_library-0.1.0.pre23 app/models/accept.rb
enju_library-0.1.0.pre22 app/models/accept.rb
enju_library-0.1.0.pre21 app/models/accept.rb
enju_library-0.1.0.pre20 app/models/accept.rb
enju_library-0.1.0.pre19 app/models/accept.rb
enju_library-0.1.0.pre18 app/models/accept.rb
enju_library-0.1.0.pre17 app/models/accept.rb
enju_library-0.1.0.pre16 app/models/accept.rb
enju_library-0.1.0.pre15 app/models/accept.rb
enju_library-0.1.0.pre14 app/models/accept.rb
enju_library-0.1.0.pre13 app/models/accept.rb