Commit 6843d0e0c1dd84cc392f4907331368dce2fb18aa
1 parent
763fff1b
Exists in
master
and in
29 other branches
Added migration to remove tracked actions
Showing
2 changed files
with
15 additions
and
0 deletions
Show diff stats
app/models/scrap.rb
@@ -11,6 +11,9 @@ class Scrap < ActiveRecord::Base | @@ -11,6 +11,9 @@ class Scrap < ActiveRecord::Base | ||
11 | 11 | ||
12 | named_scope :not_replies, :conditions => {:scrap_id => nil} | 12 | named_scope :not_replies, :conditions => {:scrap_id => nil} |
13 | 13 | ||
14 | + track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.receiver != s.sender} | ||
15 | + track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.receiver == s.sender} | ||
16 | + | ||
14 | after_create do |scrap| | 17 | after_create do |scrap| |
15 | scrap.root.update_attribute('updated_at', DateTime.now) unless scrap.root.nil? | 18 | scrap.root.update_attribute('updated_at', DateTime.now) unless scrap.root.nil? |
16 | Scrap::Notifier.deliver_mail(scrap) if scrap.send_notification? | 19 | Scrap::Notifier.deliver_mail(scrap) if scrap.send_notification? |
db/migrate/20111228202739_remove_useless_tracked_actions.rb
0 → 100644
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +class RemoveUselessTrackedActions < ActiveRecord::Migration | ||
2 | + def self.up | ||
3 | + select_all("SELECT id FROM action_tracker WHERE verb IN ('update_article', 'remove_article', 'leave_comment', 'leave_community', 'remove_member_in_community')").each do |tracker| | ||
4 | + activity = ActionTracker::Record.find_by_id(tracker['id']) | ||
5 | + activity.destroy if activity | ||
6 | + end | ||
7 | + end | ||
8 | + | ||
9 | + def self.down | ||
10 | + say "this migration can't be reverted" | ||
11 | + end | ||
12 | +end |