limit news updates to ones created in past 2 weeks

This commit is contained in:
r888888888
2013-07-11 16:20:29 -07:00
parent c520c7f03c
commit 045cfc795b

View File

@@ -1,7 +1,7 @@
class NewsUpdate < ActiveRecord::Base
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
scope :recent, order("created_at desc").limit(5)
scope :recent, lambda {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)}
before_validation :initialize_creator, :on => :create
before_validation :initialize_updater