Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jets deploy: undefined local variable or method `searchkick' for ModelName #245

noelrocha opened this issue May 8, 2019 · 3 comments


None yet
3 participants
Copy link

commented May 8, 2019

Hi! Thanks for this awesome framework. Its really helping my company to go microservices! But Im getting an weird error when adding ElasticSearch support using the searchkick gem.


  • [] Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a jets upgrade command that makes this a simple task. There's also an Upgrading Guide:
  • [ ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on
  • [ ] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.

My Environment

Software Version
Operating System macOS Mojave 10.14.3
Jets 1.8.11
Ruby 2.5.3

Expected Behaviour

It should successfully deploy my application

Current Behavior

Its giving me the following error: 'method_missing': undefined local variable or method searchkick' for ModelName`

Step-by-step reproduction instructions

  • add gem 'searchkick'
  • add searchkick to a model
  • try to deploy running jets deploy

echo "class MyModel < ApplicationRecord\n searchkick \n end" > app/models/my_model.rb
jets deploy

the jets console works like a charm, I can search on the ElasticSearch without problems.

Code Sample

Traceback (most recent call last):
	34: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'
	33: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
	32: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/bin/jets:23:in `<main>'
	31: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/bin/jets:23:in `load'
	30: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/exe/jets:14:in `<top (required)>'
	29: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/cli.rb:5:in `start'
	28: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/cli.rb:20:in `start'
	27: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/cli.rb:48:in `boot_jets'
	26: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/core.rb:18:in `boot'
	25: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/booter.rb:24:in `boot!'
	24: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/booter.rb:201:in `eager_load_app'
	23: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/booter.rb:201:in `select'
	22: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/jets-1.8.11/lib/jets/booter.rb:219:in `block in eager_load_app'
	21: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/core_ext/string/inflections.rb:68:in `constantize'
	20: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `constantize'
	19: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `inject'
	18: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `each'
	17: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:283:in `block in constantize'
	16: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:283:in `const_get'
	15: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:195:in `const_missing'
	14: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:510:in `load_missing_constant'
	13: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:356:in `require_or_load'
	12: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `load_interlock'
	11: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
	10: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
	 9: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
	 8: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
	 7: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:373:in `block in require_or_load'
	 6: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:475:in `load_file'
	 5: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:661:in `new_constants_in'
	 4: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:476:in `block in load_file'
	 3: from /Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:476:in `load'
	 2: from /Users/noelrocha/Workspace/vai-bi/app/models/invoice.rb:1:in `<top (required)>'
	 1: from /Users/noelrocha/Workspace/vai-bi/app/models/invoice.rb:4:in `<class:Invoice>'
/Users/noelrocha/.rvm/gems/ruby-2.5.3/gems/activerecord-5.2.3/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined local variable or method `searchkick' for Invoice (call 'Invoice.connection' to establish a connection):Class (NameError)

Solution Suggestion

@noelrocha noelrocha added the bug label May 8, 2019


This comment has been minimized.

Copy link

commented May 8, 2019

Thanks for the kind words. Browsed through the source of searchkick to see if there's any special loading. Doesn't look like it 🤔 Nevertheless, if we require searchkick explicitly it works. Here are 2 options:

  1. Require it on the model


require "searchkick"
class Post < ApplicationRecord
  1. Require it as an initializer so it's available everywhere


require "searchkick"

Side note: One of the reasons, decided to eager load things as part of the jets deploy is that it helps to find issues before deployment. Feel like these issues are better found early before its running on AWS Lambda.

@tongueroo tongueroo closed this May 8, 2019


This comment has been minimized.

Copy link

commented May 9, 2019

the initializer solution worked great! thanks!


This comment has been minimized.

Copy link

commented May 11, 2019

@tongueroo I was facing similar issues with closure_tree and fast_jsonapi. Loading both gems in initializers solved the issue.

IMHO jets initializers documentation should be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.