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

Created on 21 Jan 2018  ·  8Comments  ·  Source: lostisland/faraday

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)

Most helpful comment

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.

All 8 comments

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.

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

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

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

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.

No worries!
Thank you very much for the update.

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.

@mattdrewitt thank you for this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

subvertallchris picture subvertallchris  ·  5Comments

asf-stripe picture asf-stripe  ·  3Comments

ioquatix picture ioquatix  ·  4Comments

jeffb-stell picture jeffb-stell  ·  5Comments

luizkowalski picture luizkowalski  ·  3Comments