Created
June 4, 2014 19:19
-
-
Save Ross-Hunter/43b85dd2af1d70bad97a 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_one :avatar, through: :profile | |
end | |
class Profile | |
belongs_to :user | |
has_one :avatar | |
end | |
class Avatar | |
belongs_to :profile | |
end | |
##Migration | |
class AddAvatarRefToUsers < ActiveRecord::Migration | |
def change | |
add_reference :avatar, :profile, index: true | |
add_reference :profile, :user, index: true | |
end | |
end | |
user.avatar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment