Sha256: 2422a36fae211d02ca6c5ca7ce4de6cc2902ef1d7a3b3f173dfe4e7f2f6cb4fe

Contents?: true

Size: 934 Bytes

Versions: 14

Compression:

Stored size: 934 Bytes

Contents

class Subscription < ApplicationRecord
  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
#  updated_at       :datetime
#

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
enju_library-0.3.11 app/models/subscription.rb
enju_library-0.3.10 app/models/subscription.rb
enju_library-0.3.9 app/models/subscription.rb
enju_library-0.3.8 app/models/subscription.rb
enju_library-0.3.8.rc.2 app/models/subscription.rb
enju_library-0.3.8.rc.1 app/models/subscription.rb
enju_library-0.3.7 app/models/subscription.rb
enju_library-0.3.6 app/models/subscription.rb
enju_library-0.4.0.beta.4 app/models/subscription.rb
enju_library-0.4.0.beta.3 app/models/subscription.rb
enju_library-0.4.0.beta.2 app/models/subscription.rb
enju_library-0.4.0.beta.1 app/models/subscription.rb
enju_library-0.3.5 app/models/subscription.rb
enju_library-0.3.4 app/models/subscription.rb