Revision bb3572ff
Added by Daniel Lobato Garcia over 8 years ago
app/models/trend_counter.rb | ||
---|---|---|
belongs_to :trend
|
||
validates :count, :numericality => {:greater_than_or_equal_to => 0}
|
||
validates :created_at, :uniqueness => {:scope => :trend_id}
|
||
default_scope lambda { order(:created_at) }
|
||
scope :recent, lambda { |*args| where("created_at > ?", (args.first || 30.day.ago) ).order(:created_at) }
|
||
default_scope -> { order(:created_at) }
|
||
scope :recent, ->(*args) { where("created_at > ?", (args.first || 30.day.ago) ).order(:created_at) }
|
||
end
|
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.