Adds Merit::Point#created_at attribute.
Points granting history is now logged.
- Attribute
points
and methodpoints=
don't exist anymore (methodpoints
still works for querying number of points for a resource). - There are new methods
add_points(num_points, log_message)
andremove_points(num_points, log_message)
in meritable resources to manually change their amount of points, keeping a history log.
Run the following migration to have the new DB tables:
class UpgradeMerit < ActiveRecord::Migration
def self.up
create_table :merit_scores do |t|
t.references :sash
t.string :category, :default => 'default'
end
create_table :merit_score_points do |t|
t.references :score
t.integer :num_points, :default => 0
t.string :log
end
end
def self.down
drop_table :merit_scores
drop_table :merit_score_points
end
end
# This will create a single point entry log, with previous points granted
# to each meritable resource. Code example for a User class.
class UpgradeMeritableResources < ActiveRecord::Migration
def up
User.find_each do |user|
user.sash.scores << Merit::Score.create
user.add_points(user.points, 'Initial merit points import.')
end
remove_column :users, :points
end
end
badges_sashes
table gets a primary key id
column. Run the following migration:
class AddIdToBadgesSashes < ActiveRecord::Migration
def self.up
add_column :badges_sashes, :id, :primary_key
end
def self.down
remove_column :badges_sashes, :id
end
end
set_notified!(badge = nil, sash = nil)
no longer exists, just call set_notified!
over the badge_sash
object, with no parameters.
Adds allow_multiple
boolean option to Badge#grant_to
(defaults to
false
). If you used this method to grant a badge it will now grant only if
resource doesn't have the badge.
Use badge.grant_to resource, :allow_multiple => true
where needed.
No changes needed. Adds Mongoid support.
No changes needed. Adds :multiple
boolean option to grant_on
to grant
badge multiple times.
MeritBadgeRules, MeritPointRules and MeritRankRules are now namespaced into Merit module. Move and change:
app/models/merit_{badge|point|rank}_rules.rb -> app/models/merit/{badge|point|rank}_rules.rb
-class Merit{Badge|Point|Rank}Rules - include Merit::{Badge|Point|Rank}Rules +module Merit + class {Badge|Point|Rank}Rules + include Merit::{Badge|Point|Rank}RulesMethods
Add log:string column to merit_actions table.
Rankings are now integer attributes (level), they are not badges anymore. set_rank doesn't accept badge_name anymore.
Badges data is now stored in config/initializers/merit.rb using ambry syntax (not in the DB anymore, as that table needed to be in sync in all development environments).
Added had_errors boolean attribute to merit_actions table.