未定义的局部变量或方法' searchkick'

时间:2022-04-26 11:31:52

I'm trying to add Searchkick to my Rails application. I'm following the exact instructions on the Get started page but I keep getting the following error:

我正在尝试将Searchkick添加到Rails应用程序中。我在开始的页面上遵循了正确的指示但是我一直有以下错误:

Started GET "/airports" for 10.0.2.2 at 2014-05-26 10:20:33 +0000
Processing by AirportsController#index as HTML
Completed 500 Internal Server Error in 26ms

NameError (undefined local variable or method `searchkick' for #<Class:0xb48f3ba8>):
  app/models/airport.rb:2:in `<class:Airport>'
  app/models/airport.rb:1:in `<top (required)>'
  app/controllers/airports_controller.rb:3:in `index'


  Rendered /home/vagrant/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.5ms)
  Rendered /home/vagrant/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.2ms)
  Rendered /home/vagrant/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.9ms)
  Rendered /home/vagrant/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (19.8ms)

Here's what the Airport model looks like:

机场模型是这样的:

# ./app/models/airport.rb
class Airport < ActiveRecord::Base
    searchkick
end

And this is what the Airport controller looks like:

这就是机场管制员的样子:

# ./app/controllers/airports_controller/rb
class AirportsController < ApplicationController
  def index
    @airports = Airport.all
  end
end

What's causing this?

是什么导致了这个呢?

1 个解决方案

#1


4  

Restart the server. The server has to be restarted after a change is made to the Gemfile.

重新启动服务器。在修改Gemfile之后,服务器必须重新启动。

Other things you can try if that doesn't work:

如果不奏效,你可以尝试其他方法:

  • add gem 'searchkick' to the Gemfile
  • 将gem 'searchkick'添加到Gemfile中
  • bundle install
  • 包安装

#1


4  

Restart the server. The server has to be restarted after a change is made to the Gemfile.

重新启动服务器。在修改Gemfile之后,服务器必须重新启动。

Other things you can try if that doesn't work:

如果不奏效,你可以尝试其他方法:

  • add gem 'searchkick' to the Gemfile
  • 将gem 'searchkick'添加到Gemfile中
  • bundle install
  • 包安装