Sha256: 59016bf6be56fb59cf99b0011c0c9d0132ccecb11f9abb35c58fdc58dea625bc

Contents?: true

Size: 720 Bytes

Versions: 5

Compression:

Stored size: 720 Bytes

Contents

module Intro
  class TourHistory < ActiveRecord::Base
    attr_accessible :tour_id, :user_id, :touch_count if Rails::VERSION::MAJOR < 4

    belongs_to :tour, class_name: 'Intro::Tour'
    belongs_to :user, class_name: Intro.config.user_class.classify

    validates :tour, :user, presence: true

    scope :with_user_and_tour, ->(user, tour) { where(user_id: user, tour_id: tour) }
    scope :ge_max_touch, -> { where('touch_count >= ?', Intro.config.max_touch_count) }
  end
end

Intro.config.user_class.classify.constantize.has_many :intro_tour_histories,
                                                      class_name: 'Intro::TourHistory',
                                                      dependent: :destroy

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
intro-0.4.1 app/models/intro/tour_history.rb
intro-0.4.0 app/models/intro/tour_history.rb
intro-0.3.0 app/models/intro/tour_history.rb
intro-0.2.0 app/models/intro/tour_history.rb
intro-0.1.0 app/models/intro/tour_history.rb