avo
avo copied to clipboard
Allow proc on filter `self.name` and `self.button_label`
Feature
Allow callable name
and button_label
on filters to ensure that localization is applied on each request.
class Avo::Filters::Club < Avo::Filters::TextFilter
self.name = -> { I18n.t("avo.filter_translations.club.name") }
self.button_label = -> { I18n.t("avo.filter_translations.club.button_label") }
def apply(request, query, value)
query.joins(:club).where("clubs.name ILIKE ?", "%#{value}%")
end
end