Sha256: a8bd4dfdd59720439ff4e2c4a8d76f92ccad7b342aa40f19286c3a4597cccdf7

Contents?: true

Size: 1.19 KB

Versions: 105

Compression:

Stored size: 1.19 KB

Contents

class Shelf < ActiveRecord::Base
  include MasterModel
  default_scope :order => "position"
  scope :real, where('library_id != 1')
  belongs_to :library, :validate => true
  has_many :items, :include => [:circulation_status]
  has_many :picture_files, :as => :picture_attachable, :dependent => :destroy

  validates_associated :library
  validates_presence_of :library
  validates_uniqueness_of :display_name, :scope => :library_id

  acts_as_list :scope => :library

  def self.per_page
    10
  end

  def web_shelf?
    return true if self.id == 1
    false
  end

  def self.web
    Shelf.find(1)
  end

  def first?
    # 必ずposition順に並んでいる
    return true if library.shelves.first.position == position
    false
  end

  def localized_display_name
    display_name.localize
  end
end

# == Schema Information
#
# Table name: shelves
#
#  id           :integer         not null, primary key
#  name         :string(255)     not null
#  display_name :text
#  note         :text
#  library_id   :integer         default(1), not null
#  items_count  :integer         default(0), not null
#  position     :integer
#  created_at   :datetime
#  updated_at   :datetime
#  deleted_at   :datetime
#

Version data entries

105 entries across 105 versions & 4 rubygems

Version Path
enju_circulation-0.0.38 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.37 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.36 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.35 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.34 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.0.3 spec/dummy/app/models/shelf.rb
enju_event-0.0.18 spec/dummy/app/models/shelf.rb
enju_event-0.0.17 spec/dummy/app/models/shelf.rb
enju_event-0.1.5 spec/dummy/app/models/shelf.rb
enju_event-0.0.16 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.33 spec/dummy/app/models/shelf.rb
enju_event-0.1.4 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.32 spec/dummy/app/models/shelf.rb
enju_event-0.1.3 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.31 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.30 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.29 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.28 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.27 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.26 spec/dummy/app/models/shelf.rb