-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add possibility to have custom search on model #3019
Conversation
begin | ||
# if you're using pg_search, the method is not defined | ||
# eventhough it's there | ||
scope = scope.rails_admin_search(options[:query]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search method's name should be configurable via DSL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the time being, it's good to have this one;
I'll work on making it configurable from Rails Admin's model config later on.
Let me know if you wish me to proceed with the second one before pulling.
-- Btw, this little fix saved me hours and hours of building a custom search page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configurability is a key part of RailsAdmin, I don't merge this without it.
Also, having tests to make sure that this feature works is mandatory.
@mshibuya I've moved the
|
Based on your idea, 9abc7f9 is now in the master. |
@mshibuya excellent ! thanks :-) |
Ah, I forgot to mention that I've made slight modification to the DSL. |
You can now add a scope
rails_admin_search
that allows you to override the default search method. This will be useful for people who wants to search with joined model;For example, if you're using
globalize
and the model'sname
column is translated, currently it fails to search for the correct one, but withpg_search
and some minor basic querying withpg_search
you'll be able to find your needed result.Example of usage: