Last active
August 29, 2015 14:02
-
-
Save Ross-Hunter/f2539f3e2fd09ad4eb5c 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 # inverse_of :profile not necessary in 4.1+ | |
end | |
class Profile | |
belongs_to :user # inverse_of :user not necessary in 4.1+ | |
end | |
##Migration | |
class AddUserRefToProfiles < ActiveRecord::Migration | |
def change | |
add_reference :profile, :user, index: true # adds user_id to profile table | |
end | |
end | |
user.profile | |
profile.user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment