Class: Spree::Api::CountriesController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Instance Method Details

#indexObject



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

def index
  @countries = Country.
    accessible_by(current_ability, :read).
    ransack(params[:q]).
    result.
    order('name ASC')

  country = Country.order("updated_at ASC").last

  if stale?(country)
    @countries = paginate(@countries)
    respond_with(@countries)
  end
end

#showObject



21
22
23
24
# File 'app/controllers/spree/api/countries_controller.rb', line 21

def show
  @country = Country.accessible_by(current_ability, :read).find(params[:id])
  respond_with(@country)
end