Class: Spree::Api::StatesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/states_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#content_type, #map_nested_attributes_keys, #permitted_line_item_attributes

Methods included from ControllerSetup

included

Instance Method Details

#indexObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/api/states_controller.rb', line 8

def index
  @states = scope.ransack(params[:q]).result.
              includes(:country).order('name ASC')

  if params[:page] || params[:per_page]
    @states = @states.page(params[:page]).per(params[:per_page])
  end

  state = @states.last
  if stale?(state)
    respond_with(@states)
  end
end

#showObject



22
23
24
25
# File 'app/controllers/spree/api/states_controller.rb', line 22

def show
  @state = scope.find(params[:id])
  respond_with(@state)
end