Sha256: bd2244771a3bf4a79b637aed9b4afdec09da6ba381652a8585db3ce75d517d86
Contents?: true
Size: 592 Bytes
Versions: 5
Compression:
Stored size: 592 Bytes
Contents
class Trend < ActiveRecord::Base belongs_to :trendable, :polymorphic => true has_many :trend_counters, :dependent => :destroy scope :has_value, where('fact_value IS NOT NULL').order("LOWER(fact_value)") scope :types, where('fact_value IS NULL') after_save :create_values, :if => lambda{ |o| o.fact_value == nil } after_destroy :destroy_values, :if => lambda{ |o| o.fact_value == nil } def to_param "#{id}-#{to_label.parameterize}" end private def destroy_values ids = [] Trend.delete_all(:id => ids) TrendCounter.delete_all(:trend_id => ids) end end
Version data entries
5 entries across 5 versions & 1 rubygems