Impressionist

Episode #2 by Teacher's Avatar David Kimura

Summary

A lightweight plugin that logs impressions per action or manually per model
view analytics rails 5:50

Resources

Summary

# Gemfile
     gem 'impressionist'

# bash
    bundle install
    rails g impressionist
    rake db:migrate

# blogs_controller.rb
    BlogsController < ApplicationController
      impressionist :actions=>[:show,:index]
    end

    def show
      @blog = Blog.find
      impressionist(@blog, "message...") # 2nd argument is optional
    end    

# blog.rb
    class Blog < ActiveRecord::Base
      is_impressionable
    end

# index.html.erb
    @blog.impressionist_count