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
We have a model which declares accepts_nested_attributes_for on one of its has_many associations. When we try to call fields_for for that association, we get a TypeError: "can't convert nil into String". This is coming from ActionView's FormHelper class:
Have you seen this problem before? We're considering extending Erector::RailsFormBuilder to implement fields_for_with_nested_attributes in a manner similar to the way you've done form_for and fields_for. Would you recommend this approach, or something else?
Thanks from the Grockit team.
The text was updated successfully, but these errors were encountered:
You can disregard this, it turns out; we think this may just be an idiosyncrasy of combining Erector 0.8.1 with Rails 2.3.2. The problem was this line from ActionView::Helpers::FormBuilder#fields_for_nested_model:
@template.concat builder.hidden_field(:id)
FormBuilder expects hidden_field to return a string, but Erector::RailsFormBuilder does the concatenation itself and returns nil. We came up with the following workaround:
module Erector
class RailsFormBuilder
def hidden_field(*args, &block)
template.concat(parent.hidden_field(*args, &block))
return ""
end
end
end
We have a model which declares accepts_nested_attributes_for on one of its has_many associations. When we try to call fields_for for that association, we get a TypeError: "can't convert nil into String". This is coming from ActionView's FormHelper class:
Have you seen this problem before? We're considering extending Erector::RailsFormBuilder to implement fields_for_with_nested_attributes in a manner similar to the way you've done form_for and fields_for. Would you recommend this approach, or something else?
Thanks from the Grockit team.
The text was updated successfully, but these errors were encountered: