car.rb 625 字节
Newer Older
1
class Car < ActiveRecord::Base
2

3
  has_many :bulbs
4
  has_many :foo_bulbs, :class_name => "Bulb", :conditions => { :name => 'foo' }
5 6
  has_many :frickinawesome_bulbs, :class_name => "Bulb", :conditions => { :frickinawesome => true }

7
  has_many :tyres
8 9
  has_many :engines
  has_many :wheels, :as => :wheelable
10 11 12 13

  scope :incl_tyres, includes(:tyres)
  scope :incl_engines, includes(:engines)

14 15 16
  scope :order_using_new_style,  order('name asc')
  scope :order_using_old_style,  :order => 'name asc'

17
end
18 19

class CoolCar < Car
20
  default_scope :order => 'name desc'
21 22 23
end

class FastCar < Car
24
  default_scope :order => 'name desc'
25
end