Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

stuff

  • Loading branch information...
commit 25332306a382820ec4d67d6b997f6588c73a6ac9 1 parent 73b94b3
Ryan McKillen authored
Showing with 6 additions and 6 deletions.
  1. +3 −3 app/models/alert.rb
  2. +3 −3 db/seeds.rb
View
6 app/models/alert.rb
@@ -5,16 +5,16 @@ class Alert < ActiveRecord::Base
after_create :alert_metrics_job
serialize :metrics
before_save :check_blacklist
- before_save :check_metric
+ after_save :check_metric, :if => :metrics_changed?
private
def check_blacklist
- current_user.blacklist.each {|domain| return false if self.url.match(/#{domain}/)}
+ User.find(self.user_id).blacklist.each {|domain| return false if self.url.match(/#{domain}/)}
end
def check_metric
- false if self.metrics["fmrp"] >= current_user.min_metric
+ Alert.destroy(self) if !self.metrics.nil? && User.find(self.user_id).min_metric > self.metrics["fmrp"]
end
def alert_metrics_job
View
6 db/seeds.rb
@@ -11,9 +11,9 @@
user = User.create!(
:username => "workingpoint",
:email => "rmckillen@workingpoint.com",
- :password => "workingpoint1",
- :password_confirmation => "workingpoint1",
- :min_metric => 3,
+ :password => "workingpoint45",
+ :password_confirmation => "workingpoint45",
+ :min_metric => 3.00,
:blacklist => %w(craigslist.com twitter.com topsy.com xmarks.com tweetmeme.com)
)
Please sign in to comment.
Something went wrong with that request. Please try again.