Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (22 sloc) 0.757 kb
= Sortable By
by Matthias Hennemeyer <mhennemeyer@gmail.com>
== Introduction
Rails Plugin.
Make Collections of ActiveRecord Models sortable by a specified attribute.
== Usage
Just declare it inside the model: (Model should have a price attribute in this case)
class Model < ActiveRecord::Base
sortable_by :price
end
Use it by calling sort:
@models = [
Model.create(:price => 5),
Model.create(:price => 1),
Model.create(:price => 3),
Model.create(:price => 12),
Model.create(:price => 7)
].sort.map(&:price)
# => [1,3,5,7,12]
== INSTALL:
$ ruby script/plugin install git://github.com/mhennemeyer/sortable-by.git
Copyright (c) 2008 Matthias Hennemeyer, released under the MIT license
Jump to Line
Something went wrong with that request. Please try again.