Sha256: e4186d0df9b3ca6257acea071749006dd5c09719f69092226018d14c51b4b9c1

Contents?: true

Size: 970 Bytes

Versions: 4

Compression:

Stored size: 970 Bytes

Contents

class Subscription < ActiveRecord::Base
  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

4 entries across 4 versions & 1 rubygems

Version Path
enju_library-0.1.0.pre43 app/models/subscription.rb
enju_library-0.1.0.pre42 app/models/subscription.rb
enju_library-0.1.0.pre41 app/models/subscription.rb
enju_library-0.1.0.pre40 app/models/subscription.rb