Skip to content

Instantly share code, notes, and snippets.

@patricksrobertson
Created February 24, 2012 16:58
Show Gist options
  • Save patricksrobertson/1902016 to your computer and use it in GitHub Desktop.
Save patricksrobertson/1902016 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :cars
end
class Color < ActiveRecord::Base
belongs_to :car
delegate :name, :to => :car, :prefix => true
end
class Car < ActiveRecord::Base
belongs_to :user
has_one :color
end
Car.first.color_name
#=> "some color"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment