zorab47 / active_admin-sortable_tree

Show ActiveAdmin index as a nested tree with drag'n'drop
MIT License
163 stars 127 forks source link

Parameters not found #84

Closed LeoAdamek closed 4 years ago

LeoAdamek commented 4 years ago
NoMethodError in Admin::LocationsController#sort
undefined method `each_pair' for nil:NilClass
Extracted source (around line #28):
#26 
#27         records = []
*28         params[resource_name].each_pair do |resource, parent_resource|
#29           parent_resource = resource_class.find(parent_resource) rescue nil
#30           records << [resource_class.find(resource), parent_resource]
#31         end

In this case I've extracted that resource_name is set to "location" which is correct, however these are the parameters sent:

{"location_8210a9d8-fc26-406f-b38a"=>{"282ca5116e0f"=>"null"}, "location_9bccc054-7515-427b-b7b4"=>{"7f054d2d18ed"=>"282ca5116e0f"}, "location_594b7e0d-59f2-4870-9ae5"=>{"92588723f6a1"=>"7f054d2d18ed"}, "location_eb46c8a6-1ca7-4fbd-866d"=>{"a81396ac35d4"=>"92588723f6a1"}, "location_a56f88ea-e891-4819-bf43"=>{"0e61ac2baf34"=>"a81396ac35d4"}, "location_509cc151-e133-45e9-9f9a"=>{"e8a89dffb09e"=>"0e61ac2baf34"}, "location_53a20efe-d2ed-4886-8312"=>{"2422179a7855"=>"0e61ac2baf34"}, "location_dfff7b16-f585-4c9d-9502"=>{"6f18ea408ca2"=>"0e61ac2baf34"}, "location_eabf1bef-f884-428f-94ce"=>{"7e84a90b3c3d"=>"0e61ac2baf34"}, "location_debf16b0-58dd-4816-9fa9"=>{"cd6b779c5a38"=>"0e61ac2baf34"}, "location_7e6b0130-0848-4620-b823"=>{"f7c2805a7e55"=>"0e61ac2baf34"}, "controller"=>"admin/locations", "action"=>"sort"}

As you can see there is no parameter for "location" but a number of parameters prefixed with location_ and then the identifier for the model instance.

Is there something I've configured incorrectly?

cprodhomme commented 4 years ago

same problem for me

i think the problem comes from the UUID :/

cprodhomme commented 4 years ago

I have made a fix in the PR https://github.com/zorab47/active_admin-sortable_tree/pull/85

@zorab47 please check my PR 🙏 and made a new version of your gem

@LeoAdamek you can use my repo for now https://github.com/Captive-Studio/active_admin-sortable_tree

zorab47 commented 4 years ago

Thanks, I’ll check it out

On Fri, Feb 21, 2020 at 11:47 cprodhomme notifications@github.com wrote:

I have made a fix in the PR #85 https://github.com/zorab47/active_admin-sortable_tree/pull/85

@zorab47 https://github.com/zorab47 please check my PR 🙏 and made a new version of your gem

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zorab47/active_admin-sortable_tree/issues/84?email_source=notifications&email_token=AAAGEBTGPKKAET4WNKTVDFTREAHSJA5CNFSM4KXGDKWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMTPCIA#issuecomment-589754656, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGEBXZU37RT4XMASSD6LDREAHSJANCNFSM4KXGDKWA .