Class: AlertsController
Constant Summary
ApplicationController::ALLOWABLE_CONFIGS
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/alerts_controller.rb', line 17
def create
respond_to do |format|
format.json do
alert = Alert.create(alert_params)
if alert.errors.any?
render json: alert.errors.full_messages, status: :unprocessable_entity
else
alert.run
render json: alert, status: :created
end
end
end
end
|
#destroy ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/controllers/alerts_controller.rb', line 54
def destroy
respond_to do |format|
format.json do
@alert.destroy!
render json: @alert
end
end
end
|
#index ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/alerts_controller.rb', line 7
def index
respond_to do |format|
format.html
format.json do
@paginated_alerts = Alert.paginated(@alerts, )
render json: @paginated_alerts
end
end
end
|
#show ⇒ Object
47
48
49
50
51
52
|
# File 'app/controllers/alerts_controller.rb', line 47
def show
respond_to do |format|
format.json { render json: @alert }
format.html { render template: 'application/index' }
end
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/alerts_controller.rb', line 32
def update
respond_to do |format|
format.json do
@alert.update_attributes!(alert_params)
if @alert.errors.any?
render json: @alert.errors.full_messages, status: :unprocessable_entity
else
@alert.run
render json: @alert, status: :created
end
end
end
end
|