Module: Shared::IsData::Navigation

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/shared/is_data/navigation.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#nextObject



7
8
9
10
11
12
13
14
# File 'app/models/concerns/shared/is_data/navigation.rb', line 7

def next
  base = self.class.base_class.order(id: :asc).where(['id > ?', id]).limit(1)
  if respond_to?(:project_id)
    base.with_project_id(project_id).first
  else
    base.first
  end
end

#previousObject



16
17
18
19
20
21
22
23
# File 'app/models/concerns/shared/is_data/navigation.rb', line 16

def previous
  base = self.class.base_class.order(id: :desc).where(['id < ?', id]).limit(1)
  if respond_to?(:project_id)
    base.with_project_id(project_id).first
  else
    base.first
  end
end