Monday, November 5, 2012

Re: [Rails] has_one relation and form_for

Thanks Tommaso, It works, but the user_id has this User:0x007fe37d33b5e0 no User:1, is that ok???

On Monday, November 5, 2012 6:25:23 PM UTC-4:30, Tommaso Visconti wrote:
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.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HauLu4dNT9kJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate