build method and nested forms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

build method and nested forms

fugee ohu
if i  @users.pets.build then in my form I'll have  <%= f.fields_for :pets do |pet| %> will iterate the same number of times as @user.pets.size but pet's attributes can't be found in :pet although they're available in @users.pets.attributes So I have to use : and @ together in the same form to display values from the object created in the controller by build?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8995111c-edd7-4047-a75e-0f62b2a464ae%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: build method and nested forms

Ariel Juodziukynas
What do you mean that "pet's attributes can't be found"? found where? how? show the code that doesn't work for you.

El sáb., 2 nov. 2019 a las 4:30, fugee ohu (<[hidden email]>) escribió:
if i  @users.pets.build then in my form I'll have  <%= f.fields_for :pets do |pet| %> will iterate the same number of times as @user.pets.size but pet's attributes can't be found in :pet although they're available in @users.pets.attributes So I have to use : and @ together in the same form to display values from the object created in the controller by build?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8995111c-edd7-4047-a75e-0f62b2a464ae%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcCK4HX_ePV4F71NvC%3D5kxqcnT9VJSbHYSPA6G_s_e7NSA%40mail.gmail.com.