nested_form icon indicating copy to clipboard operation
nested_form copied to clipboard

Decorator breaks #link_to_add

Open basvanwesting opened this issue 12 years ago • 5 comments
trafficstars

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.

basvanwesting avatar Jan 21 '13 22:01 basvanwesting

Could you please push a test application reproducing this issue?

lest avatar Jan 22 '13 08:01 lest

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.

basvanwesting avatar Jan 25 '13 13:01 basvanwesting

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...

basvanwesting avatar Jan 28 '13 20:01 basvanwesting

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'

basvanwesting avatar Feb 02 '13 07:02 basvanwesting

Please use the 'decorates_association_issue' branch. I have made another branch for a different issue.

basvanwesting avatar Feb 02 '13 14:02 basvanwesting