scoutapp / scout_apm_ruby

ScoutAPM Ruby Agent. Supports Rails, Sinatra, Grape, Rack, and many other frameworks

Home Page:https://scoutapm.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typhoeus in ActiveRecord before_save raises NoMethodError exception

fdeschenes opened this issue · comments

Using Typhoeus in a before_save callback raises an exception such as NoMethodError (undefined method ``merge' for "https://httpstat.us/200":String). We are using version 4.0.4 of the gem. Moving the Typhoeus call to after_save does not result in the exception being raised.

Model example:

class Team < ApplicationRecord
  before_save do
    Typhoeus.get('https://httpstat.us/200')
  end
end

Usage example:

irb(main):001:0> Team.create
  [primary] (0.2ms)  BEGIN
ETHON: Libcurl initialized
ETHON: performed EASY effective_url=https://httpstat.us/200 response_code=200 return_code=ok total_time=1.2273
Traceback (most recent call last):
        7: from (irb):1
        6: from (eval):67:in `transaction'
        5: from (eval):15:in `_makara_hijack'
        4: from (eval):71:in `block in transaction'
        3: from (eval):27:in `execute'
        2: from (eval):15:in `_makara_hijack'
        1: from (eval):31:in `block in execute'
NoMethodError (undefined method `merge' for "https://httpstat.us/200":String)

This looks like a duplicate of #391 .

I have submitted a PR to fix but it doesn't appear to have been looked at yet.

Closing this as I've merged #391. Thank you