I'm using the merit gem for rails, and would like to have a timeline of reputation changes, badges earned etc. For example
- +1 22Feb PostTitle voted up
- +3 22Feb PostTitle favorited
- -1 22Feb PostTitle voted down ....and so on.
Based on the readme, I created the following:
config/initializers/merit.rb
config.add_observer 'ReputationChangeObserver'
reputation_change_observer.rb
class ReputationChangeObserver
def update(changed_data)
# `changed_data[:description]` holds information on what changed
# badges granted or removed, points changed.
# `changed_data[:merit_object]` reputation related object created by merit.
# It responds to `sash_id` and `sash`. From there you can get to your
# application object that had it's reputation changed, for example:
# sash_id = changed_data[:merit_object].sash_id
# User.where(sash_id: sash_id).first
# You may use this to fill a timeline with notifications for users, send
# emails, etc.
end
end
Question is, what next? How do I use the observer to display a timeline of the current_user.changed_data?