Module: Katello::Api::V2::HostsControllerExtensions::Overrides

Defined in:
app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb

Instance Method Summary collapse

Instance Method Details

#action_permissionObject



9
10
11
12
13
14
15
16
# File 'app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb', line 9

def action_permission
  case params[:action]
  when 'host_collections'
    'edit'
  else
    super
  end
end

#resource_scope(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb', line 18

def resource_scope(options = {})
  scope = super(options)
  # Eager load host_collections for index action to avoid N+1 queries
  # Using preload to force loading even if not accessed
  if params[:action] == 'index' && scope.respond_to?(:preload)
    scope = scope.preload(:host_collections)
  end
  scope
end