Method: QueryReport::FilterModule#filter

Defined in:
lib/query_report/filter.rb

#filter(column, options = {}, &block) ⇒ Object

Creates a filter

Examples:

Custom type

filter :invoiced_to_id, type: :user

# In a helper file define method
def query_report_user_filter(name, user_id, options={})
  user = User.find(user_id)
  concat hidden_field_tag name, user_id, options
  text_field_tag "#{name}", user.name, class: 'user_search' #implement the filter, it can be autocomplete
end

Parameters:

  • column

    the column on which the filter is done on, for manual filter the column name can be anything

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :type (Symbol)

    date | text | whatever

  • :comp (Array)

    the comparators used for ransack search, [:gteq, :lteq]

  • :manual (Boolean)

    if set to true then that filter will not be applied, only will appear and can be used for custom application

  • :default (Object)

    support default filter value, can be one value or for range filter can be array



31
32
33
34
# File 'lib/query_report/filter.rb', line 31

def filter(column, options={}, &block)
  @filters ||= []
  @filters << Filter.new(@params, column, options, &block)
end