ruby-on-railspg-search

Pg_search: Wrong number of arguments (given 2, expected 1)


I am trying to add a search feature to my Rails 6 application using Pg_search gem.

I have added the gem to my Gemfile, and installed it using:

bundle install

However, when I start my rails server I get the error below when I try to access the application on my browser:

wrong number of arguments (given 2, expected 1) 

Here's an image of it:

image

I'm wondering what I am doing wrong.


Solution

  • I finally figured it out.

    The issue was that I was using an outdated version of the Pg_search gem in my Rails 6 application.

    Here's how I fixed it:

    I simply replaced the gem below in my Gemfile:

    gem 'pg_search', '~> 1.0'
    

    with

    gem 'pg_search', '~> 2.3'
    

    which is the latest version as of this writing.

    Note: You can simply add gem 'pg_search' to your Gemfile without specifying a version and it will install the latest version.

    That's all.

    I hope this helps