Class: Georeferences::GoogleMapsController

Inherits:
ApplicationController
  • Object
show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/georeferences/google_maps_controller.rb

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Instance Method Details

#createObject

POST /georeferences/google_maps POST /georeferences/google_maps.json



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/georeferences/google_maps_controller.rb', line 14

def create
  @georeference = Georeference::GoogleMap.new(georeference_params)
  respond_to do |format|
    if @georeference.save
      format.html do
        flash[:notice] = 'Georeference was successfully created.'
        if params[:commit_and_next]
          redirect_to new_georeferences_google_map_path(
            georeference: {
              collecting_event_id: @georeference.collecting_event.next_without_georeference
            })
        else
          redirect_to collecting_event_path(@georeference.collecting_event)
        end
      end
      format.json { render action: 'show', status: :created }
    else
      format.html { render :new }
      format.json { render json: @georeference.errors, status: :unprocessable_entity }
    end
  end
end

#georeference_paramsObject (private)



39
40
41
42
43
44
45
46
# File 'app/controllers/georeferences/google_maps_controller.rb', line 39

def georeference_params
  params.require(:georeference).permit(:collecting_event_id,
                                       :type,
                                       :is_public,
                                       :geo_type,
                                       geographic_item_attributes: [:shape]
                                      )
end

#newObject

GET /georeferences/google_maps/new



5
6
7
8
9
10
# File 'app/controllers/georeferences/google_maps_controller.rb', line 5

def new
  p = georeference_params
  p[:collecting_event] = CollectingEvent.new if p['collecting_event_id'].blank?
  p[:geographic_item] = GeographicItem.new # not required in present state - if p['geographic_item_id'].blank?
  @georeference = Georeference::GoogleMap.new(p)
end

#set_data_modelObject (private)

Over-ride the default model setting for this subclass



49
50
51
# File 'app/controllers/georeferences/google_maps_controller.rb', line 49

def set_data_model
  @data_model = Georeference::GoogleMap
end