This project is archived and is in readonly mode.
v2.3 nested attributes, forms_for, child_form.object is always nil
-
Eloy Duran
- 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
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.
Jens
-
Eloy Duran
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
Hi,
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.
Thanks!
Jens
-
Eloy Duran
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.