Skip to content

Instantly share code, notes, and snippets.

@paulelliott
Created February 18, 2011 14:04
Show Gist options
  • Save paulelliott/833687 to your computer and use it in GitHub Desktop.
Save paulelliott/833687 to your computer and use it in GitHub Desktop.
Proper Use of Fabricators - AR classes
class Manufacturer < ActiveRecord::Base
has_many :models
validates_presence_of :name
end
class Model < ActiveRecord::Base
belongs_to :manufacturer
has_many :motorcycles
validates_presence_of :name
end
class Motorcycle < ActiveRecord::Base
belongs_to :model
belongs_to :owner
validates_presence_of :vin
end
class Owner < ActiveRecord::Base
has_many :motorcycles
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment