Class: HandyLocationInputs::LocationsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Locatable
Defined in:
app/controllers/handy_location_inputs/locations_controller.rb

Instance Method Summary collapse

Instance Method Details

#citiesObject



16
17
18
19
20
# File 'app/controllers/handy_location_inputs/locations_controller.rb', line 16

def cities
  respond_to do |format|
    format.json {render json: { cities: CS.cities(state_key, country_key)}}
  end
end

#country_keyObject



22
23
24
# File 'app/controllers/handy_location_inputs/locations_controller.rb', line 22

def country_key
  CS.countries.key(params[:country])
end

#state_keyObject



26
27
28
# File 'app/controllers/handy_location_inputs/locations_controller.rb', line 26

def state_key
  return_key(CS.states(country_key), params[:state])
end

#statesObject



10
11
12
13
14
# File 'app/controllers/handy_location_inputs/locations_controller.rb', line 10

def states
  respond_to do |format|
    format.json {render json: { states: CS.states(country_key).values }}
  end
end