Sha256: 8486002eec0dfc974084f4c6ecc6dd06c969e2d712de8211c9935cb0e68763ec

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

module Merit
  class BadgesSash < ActiveRecord::Base
    include Base::BadgesSash
    has_many :activity_logs,
             class_name: Merit::ActivityLog,
             as: :related_change

    if defined?(ProtectedAttributes) || !defined?(ActionController::StrongParameters)
      attr_accessible :badge_id
    end

    # DEPRECATED: `last_granted` will be removed from merit, please refer to:
    # https://github.com/tute/merit/wiki/How-to-show-last-granted-badges
    def self.last_granted(options = {})
      warn '[merit] [DEPRECATION] `last_granted` will be removed from merit, please refer to: https://github.com/tute/merit/wiki/How-to-show-last-granted-badges'
      options[:since_date] ||= 1.month.ago
      options[:limit]      ||= 10
      where("created_at > '#{options[:since_date]}'")
        .limit(options[:limit])
        .map(&:badge)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merit-1.9.0 lib/merit/models/active_record/merit/badges_sash.rb