2010-06-27 11:17:44 -04:00
|
|
|
class Car < ActiveRecord::Base
|
2010-09-07 13:08:03 -04:00
|
|
|
|
2010-08-12 21:37:48 -04:00
|
|
|
has_many :bulbs
|
2011-04-03 19:07:45 -04:00
|
|
|
has_many :foo_bulbs, :class_name => "Bulb", :conditions => { :name => 'foo' }
|
2011-05-10 18:35:01 -04:00
|
|
|
has_many :frickinawesome_bulbs, :class_name => "Bulb", :conditions => { :frickinawesome => true }
|
|
|
|
|
2011-05-12 18:29:07 -04:00
|
|
|
has_one :bulb
|
|
|
|
has_one :frickinawesome_bulb, :class_name => "Bulb", :conditions => { :frickinawesome => true }
|
|
|
|
|
2010-08-03 17:26:59 -04:00
|
|
|
has_many :tyres
|
2011-09-06 10:58:07 -04:00
|
|
|
has_many :engines, :dependent => :destroy
|
2011-09-09 03:31:54 -04:00
|
|
|
has_many :wheels, :as => :wheelable, :dependent => :destroy
|
2010-08-03 17:26:59 -04:00
|
|
|
|
2012-03-21 18:18:18 -04:00
|
|
|
scope :incl_tyres, -> { includes(:tyres) }
|
|
|
|
scope :incl_engines, -> { includes(:engines) }
|
2010-08-03 17:26:59 -04:00
|
|
|
|
2012-03-21 18:18:18 -04:00
|
|
|
scope :order_using_new_style, -> { order('name asc') }
|
2010-09-01 12:04:29 -04:00
|
|
|
|
2010-06-27 11:17:44 -04:00
|
|
|
end
|
2010-09-07 13:08:03 -04:00
|
|
|
|
|
|
|
class CoolCar < Car
|
2012-03-21 18:18:18 -04:00
|
|
|
default_scope { order('name desc') }
|
2010-09-07 13:08:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class FastCar < Car
|
2012-03-21 18:18:18 -04:00
|
|
|
default_scope { order('name desc') }
|
2010-09-07 13:08:03 -04:00
|
|
|
end
|