Skip to content

Instantly share code, notes, and snippets.

@rystraum
Created May 15, 2013 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rystraum/5586611 to your computer and use it in GitHub Desktop.
Save rystraum/5586611 to your computer and use it in GitHub Desktop.
Ember polymorphic associations
# doctor.rb
class Doctor < ActiveRecord::Base
has_one :user, as: :profile
has_and_belongs_to_many :patients
end
# patient.rb
class Patient < ActiveRecord::Base
has_one :user, as: :profile
has_and_belongs_to_many :doctors
end
# user.rb
class User < ActiveRecord::Base
belongs_to :profile, polymorphic: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment