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

NoMethodError: undefined method `params_encoder' Ruby 2.4.0 & faraday 0.14.0 #759

Closed
PrimeTimeTran opened this issue Jan 21, 2018 · 8 comments

Comments

@PrimeTimeTran
Copy link

PrimeTimeTran commented Jan 21, 2018

Basic Info

  • Faraday Version: 0.14.0
  • Ruby Version: 2.4.0

Issue description

I'm expecting to be able to run Model.import(force: true) in the rails console and move forward with configuring my Elastic search using the elasticsearch-rails gem

This is the error/backtrace I get though.

NoMethodError: undefined method `params_encoder' for {"timeout"=>300, :proxy=>nil}:Hash
from /Users/Lois/.rvm/gems/ruby-2.4.0/gems/faraday-0.14.0/lib/faraday/request.rb:60:in `url'

Steps to reproduce:

  1. Create new rails app
    rails new elasticrails

  2. Add elastic-search gems:

gem 'elasticsearch-model', git: 'git://github.com/elastic/elasticsearch-rails.git', branch: 'master'
gem 'elasticsearch-rails', git: 'git://github.com/elastic/elasticsearch-rails.git', branch: 'master'
  1. Bundle install:
    bundle install

  2. Add model:
    rails g model Price price:integer

  3. Setup db:
    rails db:create db:migrate

  4. Include elastic-search-rails to model file:

# app/models/price.rb
class Price
  include Elasticsearch::Model
  include Elasticsearch::Model::Callbacks
  index_name([Rails.env,base_class.to_s.pluralize.underscore].join('_'))
...
end
  1. Open rails console:
    rails console

  2. Run import command:
    Price.import(force: true)

@iMacTia
Copy link
Member

iMacTia commented Jan 21, 2018

Hi @PrimeTimeTran,
thanks for the details but having also the full backtrace would help in this case rather than just the first line. I might notice the issue immediately with that, otherwise I'll need to setup the project following your steps, but that will take significantly longer.

@PrimeTimeTran
Copy link
Author

Hey @iMacTia,
That is the entire trace.
screen shot 2018-01-22 at 5 29 39 am

@iMacTia
Copy link
Member

iMacTia commented Jan 21, 2018

OK! That’s strange...
I’ll try to replicate it then and see why that happens. However I’d suggest raising this also with the elasticsearch-model or elasticsearch-Rails maintainers as it might be due to the way they use Faraday internally

@PrimeTimeTran
Copy link
Author

PrimeTimeTran commented Jan 21, 2018

Yeah, I've already opened up an issue on elasticsearch-rails, but I don't know where in their gem it's getting called from so wasn't sure what else I could tell them that's useful.

Also thanks for looking into this~! We appreciate your work

@PrimeTimeTran
Copy link
Author

I made a mistake. It has to do with the initializers I did in this blog post.
https://medium.com/@thecolorfulcrayon/configuring-elasticsearch-on-rails-8bcbe973e9e7

I'm closing this issue. My apologies. Thanks for your time.

@iMacTia
Copy link
Member

iMacTia commented Jan 22, 2018

No worries!
Thank you very much for the update.

@mattdrewitt
Copy link

For anyone who lands here from google, make sure to use deep_symbolize_keys when loading your config file as if they are mix and match you will see this problem.

@richessler
Copy link

@mattdrewitt thank you for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants