Module: AllowedActions

Extended by:
ActiveSupport::Concern
Included in:
ForemanBootdisk::Api::V2::DisksController, ForemanBootdisk::Api::V2::SubnetDisksController, ForemanBootdisk::DisksController
Defined in:
app/controllers/concerns/allowed_actions.rb

Instance Method Summary collapse

Instance Method Details

#bootdisk_type_allowed?(action = params[:action]) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/concerns/allowed_actions.rb', line 4

def bootdisk_type_allowed?(action = params[:action])
  return true if Setting::Bootdisk.allowed_types&.include?(action)

  message = _('This type of bootdisk is not allowed. Please contact administrator.')
  if api_request?
    render_error :custom_error, status: :unprocessable_entity, locals: { message: message}
  else
    error(message)
    redirect_back(fallback_location: '/')
  end
  false
end