Created
June 4, 2014 19:24
-
-
Save Ross-Hunter/d050da14afd00b5d06b7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
##Class | |
class User | |
has_one :profile | |
has_many :avatars, through: :profile | |
end | |
class Profile | |
belongs_to :user | |
has_many :avatars | |
end | |
class Avatar | |
belongs_to :profile | |
end | |
##Migration | |
class AddProfilesAndAvatarsToUsers < ActiveRecord::Migration | |
def change | |
add_reference :profile, :user, index: true | |
add_reference :avatar, :profile, index: true | |
end | |
end | |
user.avatars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment