Class: Spree::Api::V1::StatesController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#content_type, #permitted_line_item_attributes

Methods included from ControllerSetup

included

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/spree/api/v1/states_controller.rb', line 7

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

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

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

#showObject



18
19
20
21
# File 'app/controllers/spree/api/v1/states_controller.rb', line 18

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