-
Notifications
You must be signed in to change notification settings - Fork 198
Home
tute edited this page Jun 15, 2012
·
31 revisions
Not yet. See https://github.com/tute/merit/issues/7
Merit installs three new tables to the app:
-
merit_actions
is meant for internal merit usage. It is the log of "meritable" actions and who triggered them, so that then it can compute per action if points or a badge is to be granted to someone. -
sashes
defines the Sash model, which has a one-to-one relationship with your "meritable" resources. It has some internally used methods, and it avoids join models. -
badges_sashes
is a relation table between Badges and "meritable" resources. There's only one join model per app, no matter how many meritable resources it has, thanks to theSash
model. Sash indirection should be invisible for the application, and should not be used. - It also adds new attributes on each resource:
points
,sash_id
andlevel
.
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
).