Displaying 1 result from an estimated 1 matches for "activityfeedlistener".
2009 Sep 27
1
Switchboard - Easy to use global ActiveRecord event listeners
...rst, require switchboard above your rails initializer:
# environment.rb
require ''switchboard''
Rails::Initializer.run do |config|
# ...
end
Add the listeners to the Switchboard in an initializer:
# config/initializers/switchboard.rb
Switchboard.listeners << ActivityFeedListener
Then, create a listener class that defines methods for after_create,
after_update and after_destroy:
class ActivityFeedListener
class << self
def after_create(record)
description = "#{record.class.name} was created"
publish_activity_feed_items record, description...