Class: Dscf::Marketplace::ProductsController

Inherits:
ApplicationController show all
Includes:
Core::Common
Defined in:
app/controllers/dscf/marketplace/products_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#bypass_permissions_for_demo?, #pundit_user

Instance Method Details

#filterObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/dscf/marketplace/products_controller.rb', line 6

def filter
  authorize @clazz.new, :filter?
  products = @clazz.all

  # Apply Ransack filtering if q params present
  if params[:q].present?
    products = products.ransack(params[:q]).result
  end

  # Apply eager loading
  products = products.includes(eager_loaded_associations) if eager_loaded_associations.present?

  # Add serializer includes
  includes = serializer_includes_for_action(:index)
  options = {}
  options[:include] = includes if includes.present?

  render_success(data: products, serializer_options: options)
end