Triumph is a gem that not only lets you add achievements to your rails app, but lets you dynamically define new achievements (e.g. by an admin) at runtime.
To use Triumph, simply do the following:
-
Include the gem:
-
Add gem ‘triumph’ to your gemfile
-
-
Create database tables:
-
rails generate triumph
-
rake db:migrate
-
-
Add an observer on any objects you want to count for your users’ achevements
-
rails generate achievement_observer Post
-
rails generate achievement_observer Comment
-
add those observers to the ‘config.active_record.observers’ variable in config/application.rb
-
-
In your users model, add:
-
include Achievements
-
-
Restart your App!
Once you’ve installed Triumph, you can visit the achievements controller to add new achievement definitions. Each achievement must have:
-
A name
-
A description
-
A set of conditions
That’s it. You can now create new Achievements, and when a post is saved, for example, Triumph will check if the conditions are met.
For more info, see the sample app at github.com/adambray/triumph-sample.git
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright © 2011 Adam Bray. See LICENSE.txt for further details.