2013-04-02 02:43:01 -04:00
|
|
|
class AlertsController < ApplicationController
|
2013-04-06 01:05:36 -04:00
|
|
|
before_filter :authenticate_user!
|
2013-04-07 06:08:21 -04:00
|
|
|
load_and_authorize_resource
|
2013-04-02 02:43:01 -04:00
|
|
|
# GET /alerts
|
|
|
|
# GET /alerts.json
|
|
|
|
def index
|
2013-04-06 01:52:53 -04:00
|
|
|
@alerts = Alert.user_alerts(current_user.id)
|
2013-04-02 02:43:01 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # index.html.erb
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /alerts/1
|
|
|
|
# GET /alerts/1.json
|
|
|
|
def show
|
2013-04-07 06:08:21 -04:00
|
|
|
@alert = Alert.find(params[:id])
|
2013-04-02 02:43:01 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # show.html.erb
|
2013-04-03 19:35:03 -04:00
|
|
|
format.xml # show.xml.builder
|
2013-04-02 02:43:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /alerts/new
|
|
|
|
# GET /alerts/new.json
|
|
|
|
def new
|
|
|
|
@alert = Alert.new
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # new.html.erb
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /alerts/1/edit
|
|
|
|
def edit
|
2013-04-07 06:08:21 -04:00
|
|
|
@alert = Alert.find(params[:id])
|
2013-04-02 02:43:01 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# POST /alerts
|
|
|
|
# POST /alerts.json
|
|
|
|
def create
|
|
|
|
@alert = Alert.new(params[:alert])
|
2013-04-06 12:25:31 -04:00
|
|
|
@alert.user_id = current_user.id
|
2013-04-02 02:43:01 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @alert.save
|
|
|
|
format.html { redirect_to @alert, notice: 'Alert was successfully created.' }
|
|
|
|
else
|
|
|
|
format.html { render action: "new" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# PUT /alerts/1
|
|
|
|
# PUT /alerts/1.json
|
|
|
|
def update
|
2013-04-07 06:08:21 -04:00
|
|
|
@alert = Alert.find(params[:id])
|
2013-04-02 02:43:01 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @alert.update_attributes(params[:alert])
|
|
|
|
format.html { redirect_to @alert, notice: 'Alert was successfully updated.' }
|
|
|
|
else
|
|
|
|
format.html { render action: "edit" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# DELETE /alerts/1
|
|
|
|
# DELETE /alerts/1.json
|
|
|
|
def destroy
|
2013-04-07 06:08:21 -04:00
|
|
|
@alert = Alert.find(params[:id])
|
2013-04-02 02:43:01 -04:00
|
|
|
@alert.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to alerts_url }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|