Class: IshManager::MarkersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_manager/markers_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/ish_manager/markers_controller.rb', line 22

def create
  @marker = ::Gameui::Marker.new(marker_params)
  @marker.map = @map
  authorize! :create_marker, @map
  @map_id = @map.id

  if params[:image]
    @marker.image = ::Ish::ImageAsset.new :image => params[:image]
    @marker.image.save
  end
  if params[:title_image]
    @marker.title_image = ::Ish::ImageAsset.new :image => params[:title_image]
    @marker.title_image.save
  end

  respond_to do |format|
    if @marker.save
      @marker.map.touch
      format.html { redirect_to map_path(@map), notice: 'Marker was successfully created.' }
    else
      format.html { render :new }
    end
  end
end

#destroyObject



69
70
71
72
73
74
75
76
77
78
# File 'app/controllers/ish_manager/markers_controller.rb', line 69

def destroy
  @marker = ::Gameui::Marker.find params[:id]
  @map = @marker.map
  authorize! :destroy_marker, @map
  @marker.map.touch
  @marker.destroy
  respond_to do |format|
    format.html { redirect_to map_path(@map), notice: 'Marker was successfully destroyed.' }
  end
end

#editObject



18
19
20
# File 'app/controllers/ish_manager/markers_controller.rb', line 18

def edit
  authorize! :edit_marker, @map
end

#newObject

def index

  authorize! :markers, ::Gameui::Map
end


13
14
15
16
# File 'app/controllers/ish_manager/markers_controller.rb', line 13

def new
  authorize! :new_marker, ::Gameui::Map
  @marker = ::Gameui::Marker.new
end

#updateObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/ish_manager/markers_controller.rb', line 47

def update
  authorize! :update_marker, @map

  if params[:image]
    @marker.image = ::Ish::ImageAsset.new :image => params[:image]
    @marker.image.save
  end
  if params[:title_image]
    @marker.title_image = ::Ish::ImageAsset.new :image => params[:title_image]
    @marker.title_image.save
  end

  respond_to do |format|
    if @marker.update(marker_params)
      @marker.map.touch
      format.html { redirect_to maps_path(@map), notice: 'Marker was successfully updated.' }
    else
      format.html { render :edit }
    end
  end
end