Class: GeographicAreasController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- GeographicAreasController
- Defined in:
- app/controllers/geographic_areas_controller.rb
Instance Method Summary collapse
- #autocomplete ⇒ Object
-
#by_lat_long ⇒ Object
!! Almost certain @mjy did similar somewhere else too !! GET /geographic_areas/by_lat_long.json?latitude=0.0&longitude=10.1.
- #display_coordinates ⇒ Object
-
#download ⇒ Object
GET /geographic_areas/download.
- #geographic_area_params ⇒ Object private
-
#index ⇒ Object
GET /geographic_areas GET /geographic_areas.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /geographic_areas/new.
- #search ⇒ Object
-
#select_options ⇒ Object
GET /geographic_areas/select_options.json.
- #set_geographic_area ⇒ Object private
-
#show ⇒ Object
GET /geographic_areas/1 GET /geographic_areas/1.json.
Methods included from DataControllerConfiguration::SharedDataControllerConfiguration
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form
Methods included from Api::Intercept
Instance Method Details
#autocomplete ⇒ Object
42 43 44 |
# File 'app/controllers/geographic_areas_controller.rb', line 42 def autocomplete @geographic_areas = Queries::GeographicArea::Autocomplete.new(params[:term]).autocomplete end |
#by_lat_long ⇒ Object
!! Almost certain @mjy did similar somewhere else too !! GET /geographic_areas/by_lat_long.json?latitude=0.0&longitude=10.1
58 59 60 61 62 63 64 |
# File 'app/controllers/geographic_areas_controller.rb', line 58 def by_lat_long @geographic_areas = GeographicArea.find_smallest_by_lat_long( params.require(:latitude).to_f, params.require(:longitude).to_f ) render action: :autocomplete end |
#display_coordinates ⇒ Object
24 25 26 27 28 |
# File 'app/controllers/geographic_areas_controller.rb', line 24 def display_coordinates @asserted_distribution = AssertedDistribution.new @json_coors = params.to_json render partial: '/asserted_distributions/quick_form' end |
#download ⇒ Object
GET /geographic_areas/download
47 48 49 |
# File 'app/controllers/geographic_areas_controller.rb', line 47 def download send_data Export::Download.generate_csv(GeographicArea.all, type: 'text', filename: "geographic_areas_#{DateTime.now}.csv") end |
#geographic_area_params ⇒ Object (private)
73 74 75 76 77 78 |
# File 'app/controllers/geographic_areas_controller.rb', line 73 def geographic_area_params params.require(:geographic_area).permit( :name, :level0_id, :level1_id, :level2_id, :parent_id, :geographic_area_type_id, :iso_3166_a2, :iso_3166_a3, :tdwgID, :data_origin) end |
#index ⇒ Object
GET /geographic_areas GET /geographic_areas.json
8 9 10 11 |
# File 'app/controllers/geographic_areas_controller.rb', line 8 def index @recent_objects = GeographicArea.updated_in_last(2.months).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end |
#list ⇒ Object
30 31 32 |
# File 'app/controllers/geographic_areas_controller.rb', line 30 def list @geographic_areas = GeographicArea.order(:id).page(params[:page]) end |
#new ⇒ Object
GET /geographic_areas/new
20 21 22 |
# File 'app/controllers/geographic_areas_controller.rb', line 20 def new @geographic_area = GeographicArea.new end |
#search ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/controllers/geographic_areas_controller.rb', line 34 def search if params[:id].blank? redirect_to geographic_areas_path, notice: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to geographic_area_path(params[:id]) end end |
#select_options ⇒ Object
GET /geographic_areas/select_options.json
52 53 54 |
# File 'app/controllers/geographic_areas_controller.rb', line 52 def @geographic_areas = GeographicArea.select_optimized(sessions_current_user_id, sessions_current_project_id, params.permit(:target)[:target]) end |
#set_geographic_area ⇒ Object (private)
68 69 70 71 |
# File 'app/controllers/geographic_areas_controller.rb', line 68 def set_geographic_area @geographic_area = GeographicArea.find(params[:id]) @recent_object = @geographic_area end |
#show ⇒ Object
GET /geographic_areas/1 GET /geographic_areas/1.json
15 16 17 |
# File 'app/controllers/geographic_areas_controller.rb', line 15 def show # GeographicArea.idontknow() end |