Skip to content

Instantly share code, notes, and snippets.

@zakgrant
Created May 16, 2012 13:28
Show Gist options
  • Save zakgrant/2710329 to your computer and use it in GitHub Desktop.
Save zakgrant/2710329 to your computer and use it in GitHub Desktop.
Override Associations [Example of cars current and previous owner]
class Car < ActiveRecord::Base
belongs_to :owner
belongs_to :previous_owner, class_name: "Owner"
def owner(new_owner)
self.previous_owner = owner
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment