Module: ByStar::ActiveRecord
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/by_star/orm/active_record/by_star.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#next(options = {}) ⇒ Object
69 70 71 72 73 |
# File 'lib/by_star/orm/active_record/by_star.rb', line 69 def next(={}) field = self.class.by_star_start_field() value = self.send(field.split(".").last) self.class.where("#{field} > ?", value).reorder("#{field} ASC").first end |
#previous(options = {}) ⇒ Object
63 64 65 66 67 |
# File 'lib/by_star/orm/active_record/by_star.rb', line 63 def previous(={}) field = self.class.by_star_start_field() value = self.send(field.split(".").last) self.class.where("#{field} < ?", value).reorder("#{field} DESC").first end |