forked from openstreetmap/openstreetmap-website
-
Notifications
You must be signed in to change notification settings - Fork 1
/
microcosms_controller.rb
59 lines (46 loc) · 1.17 KB
/
microcosms_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
class MicrocosmsController < ApplicationController
layout "site"
before_action :authorize_web
before_action :set_microcosm, :only => [:edit, :show, :show_events, :show_members, :update]
authorize_resource
def index
@microcosms = Microcosm.order(:name)
end
# GET /microcosms/mycity
# GET /microcosms/mycity.json
def show; end
def show_members; end
def show_events; end
def edit; end
def update
respond_to do |format|
if @microcosm.update(microcosm_params)
format.html { redirect_to @microcosm, :notice => t(".success") }
else
format.html { render :edit }
end
end
end
def new
@microcosm = Microcosm.new
end
def create
@microcosm = Microcosm.new(microcosm_params)
if @microcosm.save
redirect_to microcosms_path, :notice => t(".success")
else
redirect_to microcosms_path, :notice => t(".failure")
end
end
private
def set_microcosm
@microcosm = Microcosm.friendly.find(params[:id])
end
def microcosm_params
params.require(:microcosm).permit(
:name, :location, :lat, :lon,
:min_lat, :max_lat, :min_lon, :max_lon,
:description
)
end
end