Monday, November 5, 2012

Re: [Rails] has_one relation and form_for

Jean ha scritto:
> Thanks Tomas. I tried this way, but then I get this error:
>
>
> NoMethodError in UserInformationsController#new
>
> undefined method `build' for nil:NilClass

yeah, sorry, for has_one relation the correct statement is:

def new
@user = User.find(params[:id])
@user_information = @user.build_user_information
end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate