Introduction

Ransack will help you easily add searching to your Rails application, without any additional dependencies.

There are advanced searching solutions around, like ElasticSearch or Algolia. Ransack will do the job for many Rails websites, without the need to run additional infrastructure or work in a different language. With Ransack you do it all with standard Ruby and ERB.

Ready to move beyond the basics? Use advanced features like i18n and extensive configuration options.

Ransack is supported for Rails 8.1, 8.0, 7.2 on Ruby 3.2 and later.

Databases

Ransack generates SQL through Arel, so it works with any database Active Record can talk to. Three are tested on every change and get first-class treatment for the handful of places where the SQL differs:

Database Adapters Tested in CI
PostgreSQL postgresql, and any adapter built on it such as postgis yes
MySQL / MariaDB mysql2, trilogy yes
SQLite sqlite3 yes

An adapter that subclasses one of Rails’ own is recognised as that database without any configuration. Other adapters (sqlserver, oracle_enhanced) are treated as standard SQL; they are known to work but are not tested here, and the dialect option lets you name a dialect explicitly if one of the known ones is a better fit.

Installation

To install ransack and add it to your Gemfile, run

gem 'ransack'

Bleeding edge

If you would like to use the latest updates not yet published to RubyGems, use the main branch:

gem 'ransack', :github => 'activerecord-hackery/ransack', :branch => 'main'

Demo application

The Ransack Demo application shows how to create simple and advanced search forms for your Ruby on Rails application.

Issues tracker

  • Before filing an issue, please read the Contributing Guide.
  • File an issue if a bug is caused by Ransack, is new (has not already been reported), and can be reproduced from the information you provide.
  • Please consider creating a pull request with a failing test that demonstrates the problem.
  • Contributions are welcome. :smiley:
  • Please do not use the issue tracker for personal support requests. Stack Overflow is a better place for that where a wider community can help you!

Contributions

To support the project:

  • Use Ransack in your apps, and let us know if you encounter anything that’s broken or missing. A failing spec to demonstrate the issue is awesome. A pull request with passing tests is even better!
  • Before filing an issue or pull request, be sure to read and follow the Contributing Guide.
  • Please use Stack Overflow or other sites for questions or discussion not directly related to bug reports, pull requests, or documentation improvements.
  • Spread the word on Twitter, Facebook, and elsewhere if Ransack’s been useful to you. The more people who are using the project, the quicker we can find and fix bugs!

Ransack for enterprise

Available as part of the Tidelift Subscription.

The maintainers of Ransack and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure. See the Security Policy for supported versions.

Contributors

Ransack was created by Ernie Miller and is developed and maintained by:

Alumni Maintainers

This project exists thanks to all the people who contribute. Contributors