/
locations_controller.rb
64 lines (51 loc) · 1.21 KB
/
locations_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class LocationsController < ApplicationController
def index
@locations = Location.all
respond_to do |format|
format.html
end
end
def show
@location = Location.find(params[:id])
@shops = @location.shops
respond_to do |format|
format.html
end
end
def new
@location = Location.new
respond_to do |format|
format.html
end
end
def edit
@location = Location.find(params[:id])
end
def create
@location = Location.new(params[:location])
respond_to do |format|
if @location.save
format.html { redirect_to @location, notice: 'Location was successfully created.' }
else
format.html { render action: "new" }
end
end
end
def update
@location = Location.find(params[:id])
respond_to do |format|
if @location.update_attributes(params[:location])
format.html { redirect_to @location, notice: 'Location was successfully updated.' }
else
format.html { render action: "edit" }
end
end
end
def destroy
@location = Location.find(params[:id])
@location.destroy
respond_to do |format|
format.html { redirect_to locations_url }
end
end
end