Class: Search
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Search
- Defined in:
- app/models/search.rb
Class Method Summary collapse
-
.delete_old_searches(days_old) ⇒ Object
delete old, unsaved searches.
Instance Method Summary collapse
-
#saved? ⇒ Boolean
A Search instance is considered a saved search if it has a user_id.
Class Method Details
.delete_old_searches(days_old) ⇒ Object
delete old, unsaved searches
19 20 21 22 23 24 |
# File 'app/models/search.rb', line 19 def self.delete_old_searches(days_old) raise ArgumentError, 'days_old is expected to be a number' unless days_old.is_a?(Numeric) raise ArgumentError, 'days_old is expected to be greater than 0' if days_old <= 0 where(['created_at < ? AND user_id IS NULL', Time.zone.today - days_old]).delete_all end |
Instance Method Details
#saved? ⇒ Boolean
A Search instance is considered a saved search if it has a user_id.
14 15 16 |
# File 'app/models/search.rb', line 14 def saved? user_id? end |