Sha256: 1044c2eaaaaf94b1f6df48b45ec47170d425a324e5c002c06e3621dee3db717c

Contents?: true

Size: 480 Bytes

Versions: 1

Compression:

Stored size: 480 Bytes

Contents

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

    attr_accessible :badge_id

    def self.last_granted(options = {})
      options[:since_date] ||= 1.month.ago
      options[:limit]      ||= 10
      where("created_at > '#{options[:since_date]}'").
        limit(options[:limit]).
        map(&:badge)
    end

    def badge
      Badge.find(badge_id)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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