class Filter

Schema Information

Table name: filters

id          :integer          not null, primary key
filter_type :string(255)
user_id     :integer          not null
name        :string(255)      default(""), not null
filter      :text             default(""), not null
description :text
active      :boolean          default(TRUE)
position    :integer          default(0), not null
created_at  :datetime
updated_at  :datetime

Public Instance Methods

results(scope, current_ability, filterql_options = {}) click to toggle source

exec the filter and resturns the collection

# File lib/generators/basepack/templates/filter.rb, line 34
def results(scope, current_ability, filterql_options = {})
 resource_class = self.filter_type.constantize
 resource_filter, filtered_scope = Basepack::Utils.filter(
   scope,
   { ql: self.filter },
   Basepack::Utils.model_config(resource_class),
   {
     auth_object: current_ability,
     filterql_options: filterql_options
   }
 )
 raise resource_filter.errors[:base] if resource_filter.errors[:base]

 #[resource_filter, filtered_scope]
 filtered_scope
end