From d0d9072294f9ad64c3847a7ff2f871f63c584f99 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sat, 6 Apr 2013 01:52:53 -0400 Subject: [PATCH] Fat model, skinny controller for selecting user_alerts --- app/controllers/alerts_controller.rb | 2 +- app/models/alert.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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