-
Notifications
You must be signed in to change notification settings - Fork 198
Home
- [How to grant badges on user registration using Devise](#how-to-grant-badges-on-user-registration-using-devisehttpsgithubcomtutemeritwikihow-to-grant-badges-on-user-registration-using-devise)
- How to implement notifications for users on new badges
- [How to show a points leaderboard](#how-to-show-a-points-leaderboardhttpsgithubcomtutemeritwikihow-to-show-a-points-leaderboard)
- [How to set rankings in my meritable models in the background](#how-to-set-rankings-in-my-meritable-models-in-the-backgroundhttpsgithubcomtutemeritwikihow-to-set-rankings-%28and-reputation-in-general%29-in-the-background%3f)
- How to recompute reputation for users after rules change
- Where is badges data stored
- Why not store badges in the database
- [How does merit work? (Explanation for developers)](#how-does-merit-work-explanation-for-developershttpsgithubcomtutemeritwikigeneral-merit-workflow)
Please refer to: https://github.com/tute/merit#getting-notifications.
Badges data is stored in config/initializers/merit.rb
using ambry. Ambry is ActiveModel compliant, so it has very few differences to a "normal" ActiveRecord relation.
For instance, calling badges
on an object will return an Ambry::Mapper
, over which you may call each
as with any array, or just convert it to an array with to_a
(user.badges.to_a
).
If badges are stored in a DB table, and app is deployed without synchronizing the badges data with the server's, it will raise an exception for badge not found, or methods called from merit
on nil
. Having the app rely on DB entries makes it weak and error prone. badges
table would have to be exactly the same for all developers/instances of the app, which is awckward.
Badges tend to be a stable piece of information, and, as the app's stability depend on it, makes much more sense to have that data in code, sourced controlled. If you change merit rules badges you are changing code, and so you change badges data there as well.
ambry is a small library which provides a nice interface to the store of this kind of objects, which are not code but neither harmless data. It also provides validations and nice filtering syntax.