class AlertsController < ApplicationController before_filter :authenticate_user! load_and_authorize_resource # GET /alerts # GET /alerts.json def index @alerts = Alert.user_alerts(current_user.id) respond_to do |format| format.html # index.html.erb end end # GET /alerts/1 # GET /alerts/1.json def show @alert = Alert.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml # show.xml.builder 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.find(params[:id]) end # POST /alerts # POST /alerts.json def create @alert = Alert.new(params[:alert]) @alert.user_id = current_user.id 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.find(params[:id]) 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.find(params[:id]) @alert.destroy respond_to do |format| format.html { redirect_to alerts_url } end end end