I have a User who can have 0 or 1 Profiles. In my Controller, I want to save the profile if some of the values are given, as follows:
# PUT /users/1
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
if params[:profile][:available] == 1 #available is a checkbox that stores a simple flag in the database.
@user.create_profile(params[:profile])
end
else
#some warnings and errors
end
end
The part I am wondering about is create_profile, the magic create_somerelationname. How does that compare to the magic build_somerelationname? And when should I use which?