From ed89322e60e6088fcb0e97234a0a495a4785ea04 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sat, 6 Apr 2013 01:55:37 -0400 Subject: [PATCH] Use scope for user_alerts to make it more 'railsy' --- app/models/alert.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/alert.rb b/app/models/alert.rb index 02f5ce6..db84ded 100644 --- a/app/models/alert.rb +++ b/app/models/alert.rb @@ -23,6 +23,10 @@ class Alert < ActiveRecord::Base } validates :semester, :presence => true + scope :user_alerts, lambda { |user_id| + where('Alerts.user_id = ?', user_id) + } + def alerted? @alerted end @@ -34,8 +38,4 @@ class Alert < ActiveRecord::Base def sections end - - def self.user_alerts(user_id) - Alert.where("user_id = #{user_id}") - end end