Skip to content

Instantly share code, notes, and snippets.

@miketierney
Forked from loe/gist:69444
Created February 24, 2009 20:36
Show Gist options
  • Save miketierney/69768 to your computer and use it in GitHub Desktop.
Save miketierney/69768 to your computer and use it in GitHub Desktop.
class Group < ActiveRecord::Base
belongs_to :location
validates_presence_of :name, :location_id
def self.sort(page, order)
options = {}
if order == 'location'
options[:order] = 'location_id'
else order == 'name'
options[:order] = name
end
paginate {:page => page, :per_page => 10}.merge!(options)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment