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.16 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.15 spec/dummy/app/models/shelf.rb
enju_bookmark-0.0.7 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.14 spec/dummy/app/models/shelf.rb
enju_bookmark-0.0.6 spec/dummy/app/models/shelf.rb
enju_event-0.0.9 spec/dummy/app/models/shelf.rb
enju_bookmark-0.0.5 spec/dummy/app/models/shelf.rb
enju_event-0.0.8 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.13 spec/dummy/app/models/shelf.rb
enju_event-0.0.7 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.12 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.11 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.10 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.9 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.8 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.7 spec/dummy/app/models/shelf.rb
enju_bookmark-0.0.4 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.0.1 spec/dummy/app/models/shelf.rb
enju_event-0.0.5 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.6 spec/dummy/app/models/shelf.rb