Punching Bag

Punching Bag is a hit tracking plugin for Ruby on Rails that specializes in simple trending.
Icons/chart bar
Used 13 times
Created by
A Andrea Fomera

For models you want to add hit-tracking to, in your model:


Then you're able to use the `punch` method to record a request.


Viewing the total hits, is simple:


For more information on PunchingBag and how to use it (for more hit trend analysis!) check out the GitHub. https://github.com/biola/punching_bag

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/zr4slV"
Template Source

Review the code before running this template on your machine.

run "bundle add punching_bag"

# Generate the migration file from the gem itself
rails_command("generate punching_bag")

# Migrate the database

puts "👋 That's all for now, PunchingBag is setup and ready to be added to a model!"

puts ""

puts "📝- add `acts_as_punchable` to models you wish to track hits on. Then record it in the controller with `@model.punch(request)`"

puts "For more information see the Usage Instructions: https://railsbytes.com/public/templates/zr4slV"

Sign up or Login to leave a comment.