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_inter_library_loan-0.1.0.pre7 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.1.0.pre6 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.1.0.pre5 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.1.0.pre4 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.1.0.pre3 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.1.0.pre2 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.1.0.pre spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.0.6 spec/dummy/app/models/shelf.rb
enju_inter_library_loan-0.0.5 spec/dummy/app/models/shelf.rb
enju_bookmark-0.0.19 spec/dummy/app/models/shelf.rb
enju_event-0.0.24 spec/dummy/app/models/shelf.rb
enju_bookmark-0.0.18 spec/dummy/app/models/shelf.rb
enju_event-0.0.23 spec/dummy/app/models/shelf.rb
enju_event-0.1.10 spec/dummy/app/models/shelf.rb
enju_event-0.1.9 spec/dummy/app/models/shelf.rb
enju_event-0.0.22 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.47 spec/dummy/app/models/shelf.rb
enju_event-0.0.21 spec/dummy/app/models/shelf.rb
enju_event-0.1.8 spec/dummy/app/models/shelf.rb
enju_circulation-0.0.46 spec/dummy/app/models/shelf.rb