Skip to content

Instantly share code, notes, and snippets.

@cheald
Created October 28, 2012 19:43
Show Gist options
  • Save cheald/3969641 to your computer and use it in GitHub Desktop.
Save cheald/3969641 to your computer and use it in GitHub Desktop.
def index
contacts_cancan = Contact.accessible_by(current_ability)
respond_to do |format|
format.html # index.html.erb
format.json { render json: ContactsDatatable.new(view_context, contacts_cancan) }
end
end
class ContactsDatatable
delegate :params, :h, :link_to, :number_to_currency, to: :@view
def initialize(view, contacts_cancan)
@view = view
@contacts_cancan = contacts_cancan
end
def fetch_contacts
contacts = @contacts_cancan.order("#{sort_column} #{sort_direction}")
contacts = contacts.page(page).per_page(per_page)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment