Created
May 15, 2013 19:24
-
-
Save rystraum/5586611 to your computer and use it in GitHub Desktop.
Ember polymorphic associations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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