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

Version Path
blacklight-4.9.0 app/models/search.rb
blacklight-4.8.0 app/models/search.rb
blacklight-5.10.2 app/models/search.rb
blacklight-5.10.1 app/models/search.rb
blacklight-5.10.0 app/models/search.rb
blacklight-5.9.3 app/models/search.rb
blacklight-5.9.2 app/models/search.rb
blacklight-5.9.1 app/models/search.rb
blacklight-5.9.0 app/models/search.rb
blacklight-5.8.2 app/models/search.rb
blacklight-5.8.1 app/models/search.rb
blacklight-5.8.0 app/models/search.rb
blacklight-5.7.2 app/models/search.rb
blacklight-5.5.4 app/models/search.rb
blacklight-5.7.1 app/models/search.rb
blacklight-5.7.0 app/models/search.rb
blacklight-5.6.0 app/models/search.rb
blacklight-5.5.3 app/models/search.rb
blacklight-5.5.2 app/models/search.rb
blacklight-5.5.1 app/models/search.rb