Sha256: 10ea2ed06484ad38192c0d5534aa1dc5f9df04911806b0568b59a85a37bda9eb

Contents?: true

Size: 1.02 KB

Versions: 28

Compression:

Stored size: 1.02 KB

Contents

class Subscription < ActiveRecord::Base
  attr_accessible :title, :note, :order_list_id, :user_id
  has_many :subscribes, :dependent => :destroy
  has_many :works, :through => :subscribes
  belongs_to :user, :validate => true
  if defined?(EnjuPurchasRequest)
    belongs_to :order_list, :validate => true
  end

  validates_presence_of :title, :user
  validates_associated :user

  searchable do
    text :title, :note
    time :created_at
    time :updated_at
    integer :work_ids, :multiple => true
  end

  paginates_per 10

  def subscribed(work)
    subscribes.where(:work_id => work.id).first
  end

end

# == Schema Information
#
# Table name: subscriptions
#
#  id               :integer          not null, primary key
#  title            :text             not null
#  note             :text
#  user_id          :integer
#  order_list_id    :integer
#  deleted_at       :datetime
#  subscribes_count :integer          default(0), not null
#  created_at       :datetime         not null
#  updated_at       :datetime         not null
#

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
enju_library-0.1.0.pre33 app/models/subscription.rb
enju_library-0.1.0.pre32 app/models/subscription.rb
enju_library-0.1.0.pre31 app/models/subscription.rb
enju_library-0.1.0.pre30 app/models/subscription.rb
enju_library-0.1.0.pre29 app/models/subscription.rb
enju_library-0.1.0.pre28 app/models/subscription.rb
enju_library-0.1.0.pre27 app/models/subscription.rb
enju_library-0.1.0.pre26 app/models/subscription.rb
enju_library-0.1.0.pre25 app/models/subscription.rb
enju_library-0.1.0.pre24 app/models/subscription.rb
enju_library-0.1.0.pre23 app/models/subscription.rb
enju_library-0.1.0.pre22 app/models/subscription.rb
enju_library-0.1.0.pre21 app/models/subscription.rb
enju_library-0.1.0.pre20 app/models/subscription.rb
enju_library-0.1.0.pre19 app/models/subscription.rb
enju_library-0.1.0.pre18 app/models/subscription.rb
enju_library-0.1.0.pre17 app/models/subscription.rb
enju_library-0.1.0.pre16 app/models/subscription.rb
enju_library-0.1.0.pre15 app/models/subscription.rb
enju_library-0.1.0.pre14 app/models/subscription.rb