Sha256: 9a7aee3c0893a443db8944af29a383b6a2f328e83749fd1f0a8065407a00c422

Contents?: true

Size: 819 Bytes

Versions: 23

Compression:

Stored size: 819 Bytes

Contents

class Withdraw < ActiveRecord::Base
  belongs_to :basket
  belongs_to :item, touch: true
  belongs_to :librarian, class_name: 'User'

  validates :item_id,
    uniqueness: true, #{ message: I18n.t('withdraw.already_withdrawn', locale: I18n.default_locale) },
    presence: true #, { message: I18n.translate('withdraw.item_not_found', locale: I18n.default_locale) }
  validates_presence_of :basket_id
  validate :check_item

  attr_accessor :item_identifier

  paginates_per 10

  def check_item
    errors.add(:item) if item.try(:rent?)
  end
end

# == Schema Information
#
# Table name: withdraws
#
#  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

23 entries across 21 versions & 2 rubygems

Version Path
enju_library-0.2.0.beta.3 app/models/withdraw.rb
enju_library-0.2.0.beta.2 app/models/withdraw.rb
enju_library-0.2.0.beta.1 app/models/withdraw.rb