Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by Polymorphic Field #2063

Closed
jeremiahlukus opened this issue Nov 17, 2021 · 3 comments
Closed

Search by Polymorphic Field #2063

jeremiahlukus opened this issue Nov 17, 2021 · 3 comments
Labels
bug breakages in functionality that is implemented

Comments

@jeremiahlukus
Copy link

  • What were you trying to do?
    I have a Subscription Dashboard that has a field owner: Field::Polymorphic I would like to be able to search by owner attributes

  • What versions are you running?

    • Rails gem "rails", "~> 6.1.0"
    • administrate latest
@jeremiahlukus jeremiahlukus added the bug breakages in functionality that is implemented label Nov 17, 2021
@pablobm
Copy link
Collaborator

pablobm commented Dec 25, 2021

Thank you for your report. Indeed, polymorphic fields are tricky and our search doesn't currently support them.

Fortunately there are ways around this. It's possible to provide your own controllers that override Administrate's behaviour. This is the basis of many customisations. In this case, overriding Administrate::ApplicationController#index would be a way to do it.

Having said that, I had a look and realised that the way things are hooked up, this is not so evident in the case of customising the search. To fix this, I have opened a PR that introduces a small change that should make this easier to do, as well as provides an example of how to do it (in the specs): #2096

@pablobm
Copy link
Collaborator

pablobm commented Dec 28, 2021

Closing in favour of #2076, which is more general of this whole issue.

@pablobm pablobm closed this as completed Dec 28, 2021
@pablobm
Copy link
Collaborator

pablobm commented Feb 3, 2022

#2096 has been merged, offering a hook that can help here, along with an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug breakages in functionality that is implemented
Projects
None yet
Development

No branches or pull requests

2 participants