Module: Gridy::Controller
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/gridy/controller.rb,
lib/gridy/controller/actions.rb
Defined Under Namespace
Modules: Actions
Instance Method Summary collapse
- #gridy_collection(collection, options = {}) ⇒ Object
- #gridy_query(collection, options = {}) ⇒ Object
Instance Method Details
#gridy_collection(collection, options = {}) ⇒ Object
44 45 46 47 48 |
# File 'lib/gridy/controller.rb', line 44 def gridy_collection(collection, = {}) @ransack = gridy_query(collection, ) @pagy, @records = pagy(@ransack.result(distinct: true), items: [:items] || 20) instance_variable_set("@#{resource_name.pluralize.underscore}", @records) end |
#gridy_query(collection, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/gridy/controller.rb', line 50 def gridy_query(collection, = {}) query = {} query[self.class.resource.searchable_key] = [:q] if searchable? query[:s] = [:sort] if sortable? collection.ransack(query) end |