Search code examples
rubyransack

Can I use Ransack to search for the same value in multiple columns?


Can the Ransack gem generate a SQL search of multiple columns for the same value?

For instance, something like "users where the first name OR the last name contains 'James'".


Solution

  • Yes, here is an example:

    MyModel.search(:firstname_or_lastname_cont => "James").result