make_model_searchable adds simple searching functionality to active record models. No need to implement same search function for each model every time!
What is does?
Provides modular solution to add search functionality for selected fields. It let’s you specify which fields you want to make searchable adding searchable_attributes in model. If no field is specified, all attributes are searched.
It uses Arel — query manager that active record uses for active record query interface.
There are many improvements to be made, such as adding support for allowing to search joined associations, ability to search from numeric and date fields, and few more.
Working on this project has been awesome experience and it helped me to learn few concepts related to ruby meta-programming and Arel. Both are very interesting and broad concepts, and makes ruby much more powerful language.
I am working on improvements and would like your support to make it more better! Here is the link to repo: https://github.com/8parth/make_model_searchable
UPDATE: This gem now supports searching from joined tables. Checkout v2.0.1 for this update.
Checkout my other articles:
Thanks for reading!