Skip to content

Instantly share code, notes, and snippets.

@mgreenly
Created May 18, 2011 01:43
Show Gist options
  • Save mgreenly/977842 to your computer and use it in GitHub Desktop.
Save mgreenly/977842 to your computer and use it in GitHub Desktop.
respond_to respond_with
# apps/data_tables/orders_index.rb
class OrdersIndex < DataTable
model Order
column :order_number, :width => 300
joins :customer
column :first_name
column :last_name
end
column :memo
order [:memo, :first_name]
end
# apps/controllers/orders_controller.rb
class OrdersController < ApplicationController::Base
respond_to :html, :json
def index
render_datatable(OrdersIndex, params, format)
end
end
view
<table>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment