Sha256: c9723e4e12f6a14ab9a03b8342f137a9e47073943c1bbbd60bde43ff00cf4456

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

class Car < ActiveRecord::Base
  has_many :bulbs
  has_many :all_bulbs, -> { unscope(where: :name) }, class_name: "Bulb"
  has_many :all_bulbs2, -> { unscope(:where) }, class_name: "Bulb"
  has_many :other_bulbs, -> { unscope(where: :name).where(name: "other") }, class_name: "Bulb"
  has_many :old_bulbs, -> { rewhere(name: "old") }, class_name: "Bulb"
  has_many :funky_bulbs, class_name: "FunkyBulb", dependent: :destroy
  has_many :failed_bulbs, class_name: "FailedBulb", dependent: :destroy
  has_many :foo_bulbs, -> { where(name: "foo") }, class_name: "Bulb"
  has_many :awesome_bulbs, -> { awesome }, class_name: "Bulb"

  has_one :bulb

  has_many :tyres
  has_many :engines, dependent: :destroy, inverse_of: :my_car
  has_many :wheels, as: :wheelable, dependent: :destroy

  has_many :price_estimates, as: :estimate_of

  scope :incl_tyres, -> { includes(:tyres) }
  scope :incl_engines, -> { includes(:engines) }

  scope :order_using_new_style,  -> { order("name asc") }

  attribute :wheels_owned_at, :datetime, default: -> { Time.now }
end

class CoolCar < Car
  default_scope { order("name desc") }
end

class FastCar < Car
  default_scope { order("name desc") }
end

Version data entries

5 entries across 5 versions & 1 rubygems

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