Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Pings idea when bookmarks change
Browse files Browse the repository at this point in the history
  • Loading branch information
mezis committed Aug 26, 2013
1 parent 27dbfcf commit b1c2e18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/idea.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def self.backed_by(user)
end


# called from subresources (comments, vettings, votes)
# called from subresources (comments, vettings, votes, bookmarks)
def ping!
update_column :active_at, Time.current
end
Expand Down
9 changes: 9 additions & 0 deletions app/models/user/bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class User::Bookmark < ActiveRecord::Base

scope :idea_is, lambda { |idea| where(:idea_id => idea.id) }

after_create :ping_idea
after_destroy :ping_idea

module UserMethods
def self.included(by)
by.class_eval do
Expand All @@ -34,4 +37,10 @@ def remove!(idea)
end
end
end

private

def ping_idea
idea.ping!
end
end

0 comments on commit b1c2e18

Please sign in to comment.