diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb index a4e61d4..1fa4bad 100644 --- a/app/controllers/alerts_controller.rb +++ b/app/controllers/alerts_controller.rb @@ -3,7 +3,7 @@ class AlertsController < ApplicationController # GET /alerts # GET /alerts.json def index - @alerts = Alert.where("user_id = #{current_user.id}") + @alerts = Alert.user_alerts(current_user.id) respond_to do |format| format.html # index.html.erb diff --git a/app/models/alert.rb b/app/models/alert.rb index 3921e70..02f5ce6 100644 --- a/app/models/alert.rb +++ b/app/models/alert.rb @@ -34,4 +34,8 @@ class Alert < ActiveRecord::Base def sections end + + def self.user_alerts(user_id) + Alert.where("user_id = #{user_id}") + end end