Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scsmith/actsasadjacent
Simple rails plugin for adding the ability to get the next and previous activerecord objects. Scopes can also be defined as this makes use of named scopes under the hood. I'm not too sure this plugin is a good idea as its really just a couple of named scopes
https://github.com/scsmith/actsasadjacent
Last synced: 2 months ago
JSON representation
Simple rails plugin for adding the ability to get the next and previous activerecord objects. Scopes can also be defined as this makes use of named scopes under the hood. I'm not too sure this plugin is a good idea as its really just a couple of named scopes
- Host: GitHub
- URL: https://github.com/scsmith/actsasadjacent
- Owner: scsmith
- License: mit
- Created: 2009-12-04T14:35:33.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2009-12-08T11:36:38.000Z (about 15 years ago)
- Last Synced: 2023-04-21T06:32:01.327Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 211 KB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
Awesome Lists containing this project
README
ActsAsAdjacent
==============Simple rails plugin for adding the ability to get the next and previous activerecord objects. Scopes can also be defined as this makes use of named scopes under the hood.
in item.rb
acts_as_adjacentin controllers
@item = Item.find(5)
Item.next(5)
Item.previous(5)You can also work directly on an instance
@item.next
@item.previousThis makes use of an offset relative to the record that is passed so it will work even if records are not sequential. So if records 1,2,4,5 are present 2.next will return 4
Copyright (c) 2009 Steve Smith, released under the MIT license