1
0
Fork 0
MSU-Course-Alerter/app/controllers/alerts_controller.rb

78 lines
1.6 KiB
Ruby
Raw Normal View History

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-02 02:43:01 -04:00
# GET /alerts
# GET /alerts.json
def index
@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
@alert = Alert.user_alerts(current_user.id).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
@alert = Alert.user_alerts(current_user.id).find(params[:id])
2013-04-02 02:43:01 -04:00
end
# POST /alerts
# POST /alerts.json
def create
@alert = Alert.new(params[:alert])
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
@alert = Alert.user_alerts(current_user.id).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
@alert = Alert.user_alerts(current_user.id).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