Class: Spree::Api::BaseController

Inherits:
ActionController::Base
  • Object
show all
Includes:
ControllerSetup, Core::ControllerHelpers::Store, Core::ControllerHelpers::StrongParameters
Defined in:
app/controllers/spree/api/base_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ControllerSetup

included

Instance Attribute Details

#current_api_userObject

Returns the value of attribute current_api_user.



10
11
12
# File 'app/controllers/spree/api/base_controller.rb', line 10

def current_api_user
  @current_api_user
end

Instance Method Details

#content_typeObject



35
36
37
38
39
40
41
42
# File 'app/controllers/spree/api/base_controller.rb', line 35

def content_type
  case params[:format]
  when 'json'
    'application/json; charset=utf-8'
  when 'xml'
    'text/xml; charset=utf-8'
  end
end

#permitted_line_item_attributesObject

users should be able to set price when importing orders via api



27
28
29
30
31
32
33
# File 'app/controllers/spree/api/base_controller.rb', line 27

def permitted_line_item_attributes
  if @current_user_roles.include?('admin')
    super + [:price, :variant_id, :sku]
  else
    super
  end
end