You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use the "fields_for" helper, the form builder object is nil.
I have two models AppDomain and AppFeature having a one to many relationship.
Considering the form below :
= form_for [:admin, @admin_app_domain] do |f|
= fields_for :app_features do |app_feature_form|
- raise app_feature_form.object.inspect #=> IS NIL !!
Even though I have app_features in @admin_app_domain.app_features, app_feature_form.object is nil.
As a workaround, I tried to pass on the collection (as mentionned in rails doc http://apidock.com/rails/ActionView/Helpers/FormHelper/fields_for) and then I got the whole collection in "object" which leads me to an error in my form as I try to call an attribute method on a collection.
= form_for [:admin, @admin_app_domain] do |f|
= fields_for : app_features, @admin_app_domain.app_features do |app_feature_form|
- raise app_feature_form.object.inspect #=> IS A COLLECTION
Is it a normal behavior and in that case how are we supposed to use "fields_for" method ?
The text was updated successfully, but these errors were encountered:
When I use the "fields_for" helper, the form builder object is
nil
.I have two models
AppDomain
andAppFeature
having a one to many relationship.Considering the form below :
Even though I have app_features in
@admin_app_domain.app_features
,app_feature_form.object
isnil
.As a workaround, I tried to pass on the collection (as mentionned in rails doc http://apidock.com/rails/ActionView/Helpers/FormHelper/fields_for) and then I got the whole collection in "object" which leads me to an error in my form as I try to call an attribute method on a collection.
Is it a normal behavior and in that case how are we supposed to use "fields_for" method ?
The text was updated successfully, but these errors were encountered: