Class: Filter
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Filter
- Defined in:
- lib/generators/basepack/templates/filter.rb
Overview
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
Instance Method Summary collapse
-
#results(scope, current_ability, filterql_options = {}) ⇒ Object
exec the filter and resturns the collection.
Instance Method Details
#results(scope, current_ability, filterql_options = {}) ⇒ Object
exec the filter and resturns the collection
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/basepack/templates/filter.rb', line 34 def results(scope, current_ability, = {}) 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: } ) raise resource_filter.errors[:base] if resource_filter.errors[:base] #[resource_filter, filtered_scope] filtered_scope end |