Rails Multi Attribute Sort / Filter

375 views
Skip to first unread message

Samuel Richardson

unread,
Jan 7, 2013, 4:38:07 PM1/7/13
to rails-...@googlegroups.com
I need a quick and dirty way of doing a multi filter / sort on ActiveRecord objects.

From the front end it will be driven by the Select2 plugin with the multiple attribute enabled (http://ivaynberg.github.com/select2/).

It would be pretty trivial to write a handler but the project I'm working on is quite experimental and I just want to hack something in for now, so a gem would be ideal.

Samuel Richardson
www.richardson.co.nz | 0405 472 748

David Parry

unread,
Jan 7, 2013, 4:51:06 PM1/7/13
to rails-...@googlegroups.com
You should check out DataTables, in particular, these ruby gems:

jquery-datatables-rails
ajax-datatables-rails

I recently used them on a project to allow ajax sorting, pagination, filtering, searching and it worked brilliantly.
> --
> You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group.
> To post to this group, send email to rails-...@googlegroups.com.
> To unsubscribe from this group, send email to rails-oceani...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.

Sebastian Porto

unread,
Jan 7, 2013, 5:22:39 PM1/7/13
to rails-...@googlegroups.com
Samuel

We have been using this gem https://github.com/ernie/ransack for some simple searching and filtering in our app, might be what you are after

Sebastian

8 January 2013 8:38 AM

Samuel Richardson

unread,
Jan 7, 2013, 6:36:43 PM1/7/13
to rails-...@googlegroups.com
Perfect. Thank you.

Samuel Richardson
www.richardson.co.nz | 0405 472 748


postbox-contact.jpg

Craig Read

unread,
Jan 8, 2013, 12:51:29 AM1/8/13
to rails-...@googlegroups.com
+1 for DataTables

The following railscasts episode demonstrates creating a class for handling server-side processing, which you'll want to do if you're returning large result sets:

Rufus Post

unread,
Jan 8, 2013, 1:13:30 AM1/8/13
to rails-...@googlegroups.com
DataTables is hard to user when you can't load the whole table. Tis why I wrote this:

Reply all
Reply to author
Forward
0 new messages