Class: IshManager::MarkersController
Instance Method Summary
collapse
#basic_auth, #home, #tinymce
Instance Method Details
#create ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/ish_manager/markers_controller.rb', line 19
def create
@marker = ::Gameui::Marker.new(marker_params)
@marker.map = @map
authorize! :create_marker, @map
@map_id = @map.id
@marker.creator_profile_id = @current_profile.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
if params[:asset3d]
@marker.asset3d = ::Gameui::Asset3d.new object: params[:asset3d]
@marker.asset3d.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
puts! @marker.errors.full_messages.join(", "), "Could not create marker"
flash[:alert] = @marker.errors.full_messages
format.html { render :new }
end
end
end
|
#destroy ⇒ Object
79
80
81
82
83
84
85
86
87
88
|
# File 'app/controllers/ish_manager/markers_controller.rb', line 79
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
|
#edit ⇒ Object
13
14
15
16
17
|
# File 'app/controllers/ish_manager/markers_controller.rb', line 13
def edit
@marker = ::Gameui::Marker.unscoped.find params[:id]
@map = @marker.map
authorize! :edit_marker, @map
end
|
#new ⇒ Object
8
9
10
11
|
# File 'app/controllers/ish_manager/markers_controller.rb', line 8
def new
authorize! :new_marker, ::Gameui::Map
@marker = ::Gameui::Marker.new
end
|
#update ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/ish_manager/markers_controller.rb', line 51
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
if params[:asset3d]
@marker.asset3d = ::Gameui::Asset3d.new object: params[:asset3d]
@marker.asset3d.save
end
old_map = @marker.map
respond_to do |format|
if @marker.update(marker_params)
@marker.map.touch
old_map.touch
format.html { redirect_to location_map_editor_path(@map.id), notice: 'Marker was successfully updated.' }
else
format.html { render :edit }
end
end
end
|