Menu

Rails 2.x

Sheba Liveoak

Sorted works with rails 2.x but you will have to roll your own scopes and view helper.

Here is the named scope for your model(s):

class MyModel < ActiveRecord::Base
  named_scope :sorted, lambda { |sort, order|
    { :order =>  Sorted::Parser.new(sort, order).to_sql }
  } 
end

and the application helper method:

class ApplicationController < ActionController::Base
  def link_to_sorted(name, order, options = {})
    dup_params      = (request.get? && !params.nil?) ? params.dup : nil
    sorter          = Sorted::ViewHelpers::ActionView::SortedViewHelper.new(order, dup_params)
    options[:class] = [options[:class], sorter.css].join(' ').strip
    link_to(name.to_s, sorter.params, options)
  end
end

Related

Wiki: Home

MongoDB Logo MongoDB