для начала создаем файл в папке app/helpers/filter_helper.rb с кодом
module FilterHelper
def self.for_select_yes_no_visible_client
a = [["all visible client", -1], ["yes", 1], ["no", 0]]
a
end
def self.for_select_yes_no_need_notify
a = [["all need notify", -1], ["yes", 1], ["no", 0]]
a
end
end
для того, чтобы вызывать эти методы из хэлпера нужно сделать include YourHelperName как показано ниже и вызвать метод, применяя его к классу:
class Admin::LogTypesController < Admin::MyAdminBaseController
include FilterHelper
# search
search_filter :index, {save_session: true, search_method: :post_and_redirect, url: :admin_log_types_url, search_url: :search_admin_log_types_url , search_action: :search} do
default_order "id", 'desc'
# fields
field :visible_client, :int, :select, {
label: 'Status',
default_value: -1, ignore_value: -1,
collection: FilterHelper.for_select_yes_no_visible_client
}
field :need_notify, :int, :select, {
label: 'Status',
default_value: -1, ignore_value: -1,
collection: FilterHelper.for_select_yes_no_need_notify
}
field :name, :string, :text, {label: 'name', default_value: '', condition: :like_full, input_html: {style: "width: 240px"}}
end
...
end