Skip to content

Instantly share code, notes, and snippets.

@vijedi
Created October 11, 2012 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijedi/3869888 to your computer and use it in GitHub Desktop.
Save vijedi/3869888 to your computer and use it in GitHub Desktop.
Active Admin Sorting Tables
content do
order = case(params[:order])
when 'user_email_desc'
'email DESC'
when 'user_email_asc'
'email ASC'
else
nil
end
if(order.nil?)
users = User.all
else
users = User.order(order)
end
panel 'Users' do
section :priority => 1 do
table_for users, {:sortable => true, :class => 'index_table'} do
column('Email', :sortable => :user_email) {|user| user.email}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment