This project is archived and is in readonly mode.

#2040 ✓invalid

v2.3 nested attributes, forms_for, child_form.object is always nil

Reported by Jens | February 22nd, 2009 @ 01:06 PM | in 2.x


I installed Rails 2.3.0 using "gem install rails --source".

Then I duplicated the example in, only

a) using FudgeFormBuilder (

b) using ResourceController (

With this setup, if I access child_form.object in a partial (or within a forms_for block), like detailed on, it is nil, regardless of whether I do before to create child models.

Is this a bug in Rails, or is this a missing feature in FudgeFormBuilder (if so: what would I have to change?) or does ResourceController interfere?

In general: do custom FormBuilders which inherit from ActionView::Helpers::FormBuilder need to actively support the nested attributes display?

Thank you!


(PS: I'd like to evaluate this problem in more detail using the "nested_attributes" branch in git:// which allegedly includes a vendored current Rails 2.3 but I can't get a working checkout. Probably a problem between me and git. :-( Maybe somebody can tell me how to get a complete checkout of the right branch, including submodules etc? Thanks!)

Comments and changes to this ticket

  • Eloy Duran

    Eloy Duran February 22nd, 2009 @ 04:49 PM

    • State changed from “new” to “invalid”

    Unless the the custom form builder messes with fields_for, or other standard methods, it should just work. And I know others have in fact been using custom form builders.

    I have no experience with ResourceController; please ask for specifics about it on the available support options for it or contact the author, this is not the right place for it. The same applies to working with git, there are plenty of pages on the web which explain how to do this, or join a irc channel like #github.

  • Jens

    Jens February 22nd, 2009 @ 05:27 PM

    Thanks for your reply.

    I did all that already - IRC, Github messages, mailing list searches, Git tutorials, manpages and so on. I have also been fighting git and Github for too long and just cannot get this to work. I'm problably missing something obvious.

    I guess the bug will just have to wait until somebody else finds it, or until somebody has two minutes to explain how to do this checkout from Github so I can track the problem down.

    I'm perfectly willing to help - otherwise I wouldn't have written this bug report. I'm just stuck.


  • Eloy Duran

    Eloy Duran February 22nd, 2009 @ 05:51 PM

    Then please let us know what it is that you were trying and how it failed, otherwise the question is just a bit too ambiguous :)

  • Jens

    Jens February 24th, 2009 @ 09:04 AM


    I think I might have found the problem, but it might not be related to nested attributes alone.

    action_view/helpers/form_helper.rb:form_for is defined as follows (taken from the Rails Github source):

    # ... case record_or_name_or_array when String, Symbol object_name = record_or_name_or_array when Array object = record_or_name_or_array.last object_name = ActionController::RecordIdentifier.singular_class_name(object) # ...

    This means that if you use

    form_for(:user, ...) do |f|

    you will not get an @object instance. But if you use

    form_for(@user, ...) do |f|

    you will get an @object instance.

    At least, changing all my forms like this fixed the apparent problem I had with the custom FormBuilder.

    Can you find out whether this is intentional and why? If it is not and can be changed so that @object is instantiated regardless of the parameter format, I will perform more tests using accepts_nested_parameters_for.



  • Eloy Duran

    Eloy Duran February 24th, 2009 @ 09:23 AM

    Ah, I understand. I don't think that it should resolve the instance, I'd rather have the user specify the instance. I'd only use the symbol form when it's not a local resource, so when you're creating a form for an external resource. But you might want to double-check that on the mailing list.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket