Sha256: f982d1bd5c6a38e8de590145aa6a3f19ff31cc9875f5adececc2d8e9dc00b66e

Contents?: true

Size: 885 Bytes

Versions: 5

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

class Club < ActiveRecord::Base
  has_one :membership, touch: true
  has_many :memberships, inverse_of: false
  has_many :members, through: :memberships
  has_one :sponsor
  has_one :sponsored_member, through: :sponsor, source: :sponsorable, source_type: :Member
  belongs_to :category

  has_many :favourites, -> { where(memberships: { favourite: true }) }, through: :memberships, source: :member

  scope :general, -> { left_joins(:category).where(categories: { name: "General" }).unscope(:limit) }

  accepts_nested_attributes_for :membership

  private
    def private_method
      "I'm sorry sir, this is a *private* club, not a *pirate* club"
    end
end

class SuperClub < ActiveRecord::Base
  self.table_name = "clubs"

  has_many :memberships, class_name: "SuperMembership", foreign_key: "club_id"
  has_many :members, through: :memberships
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ibm_db-5.5.0 test/models/club.rb
ibm_db-5.4.1 test/models/club.rb
ibm_db-5.4.0 test/models/club.rb
ibm_db-5.3.2 test/models/club.rb
ibm_db-5.3.1 test/models/club.rb