Adds badge and achievement system to you app.
Inspired by : stackoverflow.com/questions/885277/how-to-implement-an-achievement-system-in-ror
Dead simple, add this to your gemfile:
gem ‘badgr’, :git => “git://github.com/Pasta/badgr.git” And then:
rails g badgr
It will add some methods to your User model (for now, the model name you can add badges onto is restricted to User) through a line you have to add into your User model: class User < ActiveRecord::Base include Achievements
It also create a migration file that you have to run through
rake db:migrate
Simply run
rails g achievement YouAchievementFantasticName
It should create you 3 files:
-
A model (YouAchievementFantasticNameAchievement), in which you have to set the condition for the badge to be earn
-
An observer (YouAchievementFantasticNameAchievementObserver), which you can destroy or modify to observe a model to award a badge
-
A test file (YouAchievementFantasticNameAchievementTest) to test the model.