Eventifier

Event tracking and notifying for active record models

Features

Tracks and logs events on active record objects Send notifications of events

Example


class EventTracking
  include Eventifier::EventTracking

  def initialize
    events_for Post do
      track_on [:create, :update, :destroy], :attributes => { :except => %w(updated_at) }
      notify :group => :members, :on => [:create, :update]
    end

    events_for Announcement do
      track_on :create, :attributes => { :except => %w(updated_at) }
      notify :group => :members, :on => :create
    end
  end
end

That’s it!

Installation

Add Eventifier to your Gemfile


  # Gemfile
  gem "eventifier"

And run bundle install

Add Eventifier to your Gemfile


  rails generate eventifier:install
  rake eventifier:install:migrations

Add notifications indicator in interface

Eventifier provides a notification tool for your users.


  # app/views/layouts/application.erb
  <div class="notifications"></div>

Add stylesheets


  # app/assets/stylesheets/application.scss
  /*= require eventifier/notifications*/

Add javascript


  # app/assets/javascripts/application.coffee
  #= require eventifier/notifications

  new NotificationDropdown el: $(".notifications")

Add the required routes


  # config/routes.rb
  mount Eventifier::Engine => '/'

Customise views


  # app/views/eventifier/dropdown/_comment.haml
  %a{ href: "#{root_url}#{url_for([object.commentable.user, object.commentable])}" }
    = image_tag object.user.photo.thumb.url, class: 'avatar'
    #{object.user.username} commented on your post

Sending of emails

Firstly, you’ll need to set the FROM address for the Eventifier mailer


  # config/initializers/eventifier.rb
  Eventifier.mailer_sender = 'Funways <[email protected]>'

You want to add a scheduled task to run the following task every x minutes


  rake eventifier:email:deliver

Requirements

  • ActiveRecord

Testing

Creating the database:

  • createdb eventifier

Spec


  rspec spec

Contributors

  • PJ Murray