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.3.1 app/models/withdraw.rb
enju_library-0.3.0 app/models/withdraw.rb
enju_library-0.3.0.rc.1 app/models/withdraw.rb
enju_library-0.3.0.beta.2 app/models/withdraw.rb
enju_library-0.2.5 app/models/withdraw.rb
enju_library-0.2.4 app/models/withdraw.rb
enju_library-0.2.3 app/models/withdraw.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/bundler/gems/enju_library-d36f415e177e/app/models/withdraw.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/enju_library-0.2.1/app/models/withdraw.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/enju_library-0.2.2/app/models/withdraw.rb
enju_library-0.2.2 app/models/withdraw.rb
enju_library-0.2.1 app/models/withdraw.rb
enju_library-0.2.0 app/models/withdraw.rb
enju_library-0.2.0.beta.10 app/models/withdraw.rb
enju_library-0.2.0.beta.9 app/models/withdraw.rb
enju_library-0.2.0.beta.8 app/models/withdraw.rb
enju_library-0.2.0.beta.7 app/models/withdraw.rb
enju_library-0.2.0.beta.6 app/models/withdraw.rb
enju_library-0.2.0.beta.5 app/models/withdraw.rb
enju_library-0.2.0.beta.4 app/models/withdraw.rb