Sha256: 5471ac6e41953542b9c86aa9d8e42be99722dfa7e685d80fda40e9662ea36316
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module Merit::Models::ActiveRecord # Sash is a container for reputation data for meritable models. It's an # indirection between meritable models and badges and scores (one to one # relationship). # # It's existence make join models like badges_users and scores_users # unnecessary. It should be transparent at the application. class Sash < ActiveRecord::Base include Merit::Models::SashConcern self.table_name = "sashes" has_many :badges_sashes, dependent: :destroy has_many :badges, through: :badges_sashes, source: :badge has_many :scores, dependent: :destroy, class_name: 'Merit::Score' after_create :create_scores # Retrieve all points from a category or none if category doesn't exist # By default retrieve all Points # @param category [String] The category # @return [ActiveRecord::Relation] containing the points def score_points(options = {}) scope = Merit::Score::Point .joins(:score) .where('merit_scores.sash_id = ?', id) if (category = options[:category]) scope = scope.where('merit_scores.category = ?', category) end scope end end end class Merit::Sash < Merit::Models::ActiveRecord::Sash; end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qalam_merit-4.5.00 | lib/merit/models/active_record/sash.rb |