Aaron Tian (Aaron)
- Aaron has 1 plugin published and has 0 fans on Railsify!
- http://aaron2ti.blogspot.com/
records_sequence by Aaron Tian (Aaron) in ActiveRecord, Toolkits, and Miscellaneous
== INSTALL == This plugin requires Rails 2.1+ currently. Install it by below command: ruby script/plugin install git://github.com/Aaron2Ti/records_sequence.git == USAGE == After installed, your ActiveRecord objects could mixin two methods "next/previous". So you could find next/previous object like below: class User < ActiveRecord::Base end foo = User.first bar = foo.next foo_neighbour = foo.previous # returns nil if foo has no previous neighbour #The sequence's sorted column is defined by the new option :sorted_by, # default is the 'id' column. foo = User.last pre_foo_sorted_by_id = foo.previous pre_foo_sorted_by_age = foo.previous(:sorted_by => 'age') #Also works fine with most other ActiveRecord's find options: foo = User.find 30 foo.next(:conditions => ['age < ?', 20]) foo.previous(:offset => 2) foo.next(:sorted_by => 'address', :order => 'name DESC, age') foo.previous( :sorted_by => 'age', :conditions => ['age < ?', 20], :order => 'name DESC, address', :offset => 2 )


