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