Revision bb3572ff
Added by Daniel Lobato Garcia over 8 years ago
app/models/trend.rb | ||
---|---|---|
class Trend < ActiveRecord::Base
|
||
validates_lengths_from_database
|
||
after_save :create_values, :if => lambda{ |o| o.fact_value.nil? }
|
||
after_destroy :destroy_values, :if => lambda{ |o| o.fact_value.nil? }
|
||
after_save :create_values, :if => ->(o) { o.fact_value.nil? }
|
||
after_destroy :destroy_values, :if => ->(o) { o.fact_value.nil? }
|
||
|
||
belongs_to :trendable, :polymorphic => true
|
||
has_many :trend_counters, :dependent => :destroy
|
||
|
||
scope :has_value, lambda { where('fact_value IS NOT NULL').order("fact_value") }
|
||
scope :types, lambda { where(:fact_value => nil) }
|
||
scope :has_value, -> { where('fact_value IS NOT NULL').order("fact_value") }
|
||
scope :types, -> { where(:fact_value => nil) }
|
||
|
||
def to_param
|
||
Parameterizable.parameterize("#{id}-#{to_label}")
|
Also available in: Unified diff
Refs #3809 - Stabby lambda syntax for oneliners
I started by spotting log.rb which didn't have a lambda wrapping its
default scope, as needed by Rails 4. Since the style guide and most
Rails 4 documents used the stabby lambda, I turned on the cop so that we
use it everywhere there's a oneliner lambda.