Skip to content

Instantly share code, notes, and snippets.

@chocnut
Created December 5, 2012 13:06
Show Gist options
  • Save chocnut/4215362 to your computer and use it in GitHub Desktop.
Save chocnut/4215362 to your computer and use it in GitHub Desktop.
association help
class BabysitterProfile < ActiveRecord::Base
belongs_to :user
has_many :references, :as => :referenceable
end
class Reference < ActiveRecord::Base
belongs_to :referenceable, :polymorphic => true
end
class TutorProfile < ActiveRecord::Base
belongs_to :user
has_many :references, :as => :referenceable
end
class User < ActiveRecord::Base
has_one :preference, :dependent=>:destroy
has_one :tutor_profile, :dependent=>:destroy
has_one :babysitter_profile, :dependent=>:destroy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment