diff options
Diffstat (limited to 'script')
-rwxr-xr-x | script/destroy_invalid_events | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/script/destroy_invalid_events b/script/destroy_invalid_events new file mode 100755 index 0000000..e9c884c --- /dev/null +++ b/script/destroy_invalid_events @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby + +ENV["RAILS_ENV"] ||= "production" +require File.dirname(__FILE__)+'/../config/environment' + +Event.find(:all).each do |event| + begin + eval("#{event.target_type}").find(event.target_id) + Project.find(event.project_id) + rescue ActiveRecord::RecordNotFound + puts "Destroying invalid event '#{event.id}:#{Action.name(event.action)}'" + event.destroy + end +end + + |