Ransack adds search forms and sortable columns to Rails apps using plain Ruby and ERB, without a separate search server. It builds SQL from named predicates and association paths.
Overview
Ransack extends Active Record models so controllers and views can accept search parameters and translate them into WHERE clauses and ORDER BY expressions. You wire forms with helpers such as search_form_for and expose sort links without hand-writing SQL for common comparisons.
Predicates encode comparisons in parameter names, including contains, greater-or-equal, and null checks on attributes. Association names in parameters trigger joins so you can filter or sort on related model fields.
Simple mode covers flat forms, while advanced mode supports nested condition groups combined with AND and OR. Authorization hooks and safe defaults are documented for controlling which attributes and associations are searchable.
Supported Rails and database combinations are listed in the project docs, including Postgres, MySQL, Trilogy, and SQLite on current Rails releases.
Key features
- Search forms for any model
- Sortable column helpers
- Rich predicate vocabulary
- Association-aware queries
- Nested AND/OR condition groups
- No external search server
- Plain Ruby and ERB integration
- Documented authorization patterns
Use cases
- Admin index filters
- User-facing record search
- Sortable data tables in Rails
- Reporting screens with ad hoc filters
- Filtering across model associations