I’m trying to create an associated form for Profiles but for some reason when I hit the submit button, I’m getting a NoMethodError which doesn’t make sense to me as my code is exactly the same as a tutorial I’m following… unless the tutorial is outdated..
def create
@user = User.find(params[:user_id])
@profile = @user.profiles.create(params[:profile])
redirect_to user_path(@user)
end
Anyone know why I’m getting the noname errors?
The form that belongs to the controller is below:
https://github.com/imjp/SuperModel/blob/master/app/views/users/show.html.erb
EDIT 1: Fixed! The following code isn’t displaying the profile data at http://localhost:3000/users/2 (which is profile#show) though: <%= @user.profile.first_name %>
Here’s my current profiles#show
def show
@user = User.find(params[:user_id])
@profile = @user.profile.find(params[:id])
end
EDIT 2: I’ve updated my github repository at https://github.com/imjp/SuperModel
why @user.profiles? try @user.profile (singular)