{"comment":{"url":"https://api.github.com/repos/rachelcolby11/Wrapt/comments/11344012","html_url":"https://github.com/rachelcolby11/Wrapt/commit/f45b815646e1103d7d9349042b8013aa49aa1a55#commitcomment-11344012","id":11344012,"user":{"login":"rachelcolby11","id":10647307,"avatar_url":"https://avatars.githubusercontent.com/u/10647307?v=3","gravatar_id":"","url":"https://api.github.com/users/rachelcolby11","html_url":"https://github.com/rachelcolby11","followers_url":"https://api.github.com/users/rachelcolby11/followers","following_url":"https://api.github.com/users/rachelcolby11/following{/other_user}","gists_url":"https://api.github.com/users/rachelcolby11/gists{/gist_id}","starred_url":"https://api.github.com/users/rachelcolby11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rachelcolby11/subscriptions","organizations_url":"https://api.github.com/users/rachelcolby11/orgs","repos_url":"https://api.github.com/users/rachelcolby11/repos","events_url":"https://api.github.com/users/rachelcolby11/events{/privacy}","received_events_url":"https://api.github.com/users/rachelcolby11/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":"","commit_id":"f45b815646e1103d7d9349042b8013aa49aa1a55","created_at":"2015-05-24T20:31:10Z","updated_at":"2015-05-24T20:31:10Z","body":"Hi Chris,\n\nThat definitely makes sense. I think I was trying to initialize an instance\nvariable (@user) to be referred to in the views (edit, new, etc), not\nassign the user to the profile, but I see why that doesn't make sense.\n\nI'm still having trouble assigning the the user to the profile in the\ncreate method though. Here is what I have now.... does it look right to you?\n\n```Ruby\ndef create\n    @user_profile = current_user.user_profile.build(user_profile_params)\n    @user_profile.user = current_user\n     if @user_profile.save\n       flash[:notice] = \"Your profile was saved.\"\n       redirect_to @user_profile\n     else\n       flash[:error] = \"There was an error. Please try again.\"\n       render :new\n     end\n   end\n```\n\nThanks so much,\n\nRachel\n\nOn Sun, May 24, 2015 at 1:15 PM, Christopher Beck <notifications@github.com>\nwrote:\n\n> Hi Rachel,\n>\n> Your intent makes total sense. But you really only need to assign the user\n> to the profile in the controller's create method. In a view like you\n> described, the current logged in user would be viewing someone else's\n> profile, as you said, but you probably would have done some sort of show\n> view somewhere where you would have set @user to be the User object you\n> find in the controller. Then you would just access the profile like this:\n>\n> @user.user_profile\n>\n> A viewer of someone else's profile would never need a new, update,\n> destroy, edit or create action / view.\n>\n> Make sense?\n>\n> C\n>\n> Sent from my iPhone\n>\n> > On May 24, 2015, at 2:43 PM, Rachel Colby <notifications@github.com>\n> wrote:\n> >\n> > Thanks so much, Chris! I'll make the changes you indicated here. The\n> reason I was trying to do @user = @user_profile.user instead of user\n> current_user is because in one of the views, current_user and the user who\n> created the user profile will be different - like if you were viewing my\n> list, you would be the current_user but I would be the user who created the\n> profile, so you'd want to see the profile for that user (me).. not\n> current_user (you).... does that make sense? I guess I haven't created that\n> view yet but how would I address that in the controller?\n>\n> >\n> > —\n> > Reply to this email directly or view it on GitHub.\n> >\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/rachelcolby11/Wrapt/commit/f45b815646e1103d7d9349042b8013aa49aa1a55#commitcomment-11343973>\n> .\n>\n"}}