« Back to blog

filtered_search refactoring

In ubiquo, the default method for searching and filtering data in the model is filtered_search. The old implementation, while flexible enough, was a bit verbose and not very pretty to look at. For example:

 

With this refactoring it is now much more concise but also more "magical". Let's see an example:

 

To sumarize:

  • the filtered_search method takes the params hash and matches filter_foo like params to named_scopes foo.
  • It also takes into account some other params like sort_order and order_by.
  • It also supports case and accent insensitive text search.

Check ubiquo_core guide for more information.

Comments (0)

Leave a comment...