nested_form
nested_form copied to clipboard
Decorator breaks #link_to_add
The link_to_add method (in v0.3.1) breaks when the model is wrapped in a decorator (Draper v1.0.0). You get a "NoMethodError: undefined method `klass' for nil:NilClass" error. This is because the model_object is derived through "class.reflect_on_association", but with a decorator the class is the decorator class.
As a workaround I was able to directly specify the model_object through the option hash of link_to_add, which solved the problem.
I'm not sure if this is a Draper issue, a nested_form issue, or if I'm doing something wrong. It seems like a Draper issue to me, but they have a "find_association_reflection" solution to the problem. So I'm unsure where to address the issue.
Could you please push a test application reproducing this issue?
Sorry for the late response, but I checked and I cannot just push the client code. This means I need to make a test app for this specific problem. I'll do that, but I need to find some time first.
I have created a test app, but am unable to reproduce the problem. So it seems the problem is more specific to the client application. I'll try reducing the client application as a different approach. But again, this will rake some time...
OK, I have a repo for you. The issue became a bit different. I could not reproduce the original issue, but I stumbled upon a related decorator issue. The repo has a green baseline commit and then a commit with the failing test case (using Capybara webkit)
https://github.com/basvanwesting/nested_form_issues_228
- see commit c7b1a8d for a green baseline spec
- see commit 150f210 breaking spec because of use 'decorates_association :books'
Please use the 'decorates_association_issue' branch. I have made another branch for a different issue.