[英]Undefined local variable or method `searchkick'
I'm trying to add Searchkick to my Rails application.我正在尝试将Searchkick添加到我的 Rails 应用程序中。 I'm following the exact instructions on the Get started page but I keep getting the following error:
我正在按照“入门”页面上的确切说明进行操作,但不断收到以下错误:
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?这是什么原因造成的?
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:如果这不起作用,您可以尝试其他事情:
gem 'searchkick'
to the Gemfilegem 'searchkick'
添加到 Gemfilebundle install
Same here.同样在这里。 I checked
gem list
, searchkick was there.我检查了
gem list
,searchkick 在那里。
But I deleted searchkick
in Gemfile and runned bundle install
.但我删除
searchkick
中的Gemfile和拼命地跑bundle install
。 Then add searchkick
and bundle install
again, it works well:)然后再次添加
searchkick
和bundle install
,效果很好:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.