Skip to content

Fix filtering by nested resource#5816

Merged
javierjulio merged 4 commits intomasterfrom
fix_filtering_by_nested_resource
Jul 25, 2019
Merged

Fix filtering by nested resource#5816
javierjulio merged 4 commits intomasterfrom
fix_filtering_by_nested_resource

Conversation

@deivid-rodriguez
Copy link
Member

After enabling a sample nested resource in #5814, I found a crash in the users page, when filtering by post.

I guess this kind of filtering is pretty uncommon (it always results in a single record), maybe it shouldn't be included by default?

Anyways, this should fix the crash, which by the way looks like this:

    And I press "Filter"                                                              # features/step_definitions/web_steps.rb:24
      undefined method `user' for #<Post:0x000055a5adf3d8d0>
      Did you mean?  super (ActionView::Template::Error)
      ./lib/active_admin/resource/routes.rb:113:in `public_send'
      ./lib/active_admin/resource/routes.rb:113:in `route_instance_params'
      ./lib/active_admin/resource/routes.rb:79:in `instance_path'
      ./lib/active_admin/resource/routes.rb:19:in `route_instance_path'
      ./lib/active_admin/view_helpers/auto_link_helper.rb:29:in `auto_url_for'
      ./lib/active_admin/view_helpers/auto_link_helper.rb:15:in `auto_link'
      ./lib/active_admin/view_helpers/display_helper.rb:78:in `pretty_format'
      ./lib/active_admin/filters/active_sidebar.rb:31:in `block (8 levels) in block'
(...)

@deivid-rodriguez deivid-rodriguez requested a review from a team July 25, 2019 20:53
@javierjulio
Copy link
Member

In regards to the question in the description, I think it would be better that ActiveAdmin didn't render all/any filters by default, instead it would have to be specified explicitly in the file. I've had trouble in the past leaving the defaults so I've been in the habit of always specifying filters on all pages.

Copy link
Member

@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks! 👌🏻

@javierjulio javierjulio merged commit 7e3eb6e into master Jul 25, 2019
@javierjulio javierjulio deleted the fix_filtering_by_nested_resource branch July 25, 2019 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants