Sha256: 63c23f3c95283ce82af9a6d647a360f3f5676b1c513a48c30aed627ee99666b2
Contents?: true
Size: 710 Bytes
Versions: 1
Compression:
Stored size: 710 Bytes
Contents
class NanoMetrics::Context < ActiveRecord::Base self.table_name = 'nano_contexts' has_many :metrics, class_name: 'NanoMetrics::Metric' belongs_to :metricable, polymorphic: true validates :metricable, presence: true validates :action, presence: true, uniqueness: { scope: [:metricable_id, :metricable_type] } def self.find_or_create(action, metricable) for_action_and_metricable(action, metricable) || create( action: action, metricable: metricable ) end def self.for_action_and_metricable(action, metricable) where( action: action, metricable_id: metricable.id, metricable_type: metricable.class.name ).first end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nano_metrics-0.0.1 | app/models/nano_metrics/context.rb |