ransack

https://github.com/activerecord-hackery/ransack

Ruby

Object-based searching.

Ransack::Configuration#search_key=

The default `search_key` name is `:q`. The default key may be overridden
in an initializer file like `config/initializers/ransack.rb` as follows:

Ransack.configure do |config|
  # Name the search_key `:query` instead of the default `:q`
  config.search_key = :query
end

Sometimes there are situations when the default search parameter name
cannot be used, for instance if there were two searches on one page.
Another name can be set using the `search_key` option with Ransack
`ransack`, `search` and `@search_form_for` methods in controllers & views.

In the controller:
In the view:
<%= f.search_form_for @search, as: :log_search %>

Source | Google | Stack overflow

Edit

git clone [email protected]:activerecord-hackery/ransack.git

cd ransack

open lib/ransack/configuration.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Ransack--Configuration-search_key--for-pr


# Commit to git

git add lib/ransack/configuration.rbgit commit -m "better docs for Ransack::Configuration#search_key="


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Ransack--Configuration-search_key--for-pr

hub pull-request


# Celebrate!