Sha256: 8cbd326f4fdc9177765c475d3354362474c98745ff828007d512255d2883875d
Contents?: true
Size: 717 Bytes
Versions: 43
Compression:
Stored size: 717 Bytes
Contents
# -*- encoding : utf-8 -*- class Search < ActiveRecord::Base belongs_to :user serialize :query_params if Rails::VERSION::MAJOR < 4 attr_accessible :query_params scope :none, where(:id => nil).where("id IS NOT ?", nil) end # A Search instance is considered a saved search if it has a user_id. def saved? self.user_id? end # delete old, unsaved searches def self.delete_old_searches(days_old) raise ArgumentError.new('days_old is expected to be a number') unless days_old.is_a?(Numeric) raise ArgumentError.new('days_old is expected to be greater than 0') if days_old <= 0 self.destroy_all(['created_at < ? AND user_id IS NULL', Date.today - days_old]) end end
Version data entries
43 entries across 43 versions & 1 rubygems