简体   繁体   English

Pg_search:参数数量错误(给定 2,预期为 1)

[英]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.我正在尝试使用Pg_search gem 向我的Rails 6应用程序添加搜索功能。

I have added the gem to my Gemfile , and installed it using:我已将 gem 添加到我的Gemfile ,并使用以下方法安装它:

bundle install

However, when I start my rails server I get the error below when I try to access the application on my browser:但是,当我启动Rails 服务器时,尝试在浏览器上访问应用程序时出现以下错误:

wrong number of arguments (given 2, expected 1) 

Here's an image of it:这是它的图像:

图片

I'm wondering what I am doing wrong.我想知道我做错了什么。

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.问题是我在Rails 6应用程序中使用了过时版本的Pg_search gem。

Here's how I fixed it :这是我修复它的方法

I simply replaced the gem below in my Gemfile :我只是在我的Gemfile替换了下面的 gem :

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.注意:您可以简单地将gem 'pg_search'添加到您的 Gemfile 而不指定版本,它会安装最新版本。

That's all.就这样。

I hope this helps我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM