vectordotdev / timber-ruby

🌲 Great Ruby logging made easy.
https://timber.io
Other
154 stars 19 forks source link

undefined method `with' for Timber::CurrentContext:Class #204

Closed mrsweaters closed 5 years ago

mrsweaters commented 5 years ago

Trying to upgrade to the 3.0.0 version of the gem from a legacy integration.

Failure/Error: Timber.with_context(user_context, &block)

     NoMethodError:
       undefined method `with' for Timber::CurrentContext:Class

I'm calling this method in ApplicationController:

  def set_user_context(&block)
    if !current_user.nil?
      user_context = Timber::Contexts::User.new(id: current_user.id)
      Timber.with_context(user_context, &block)
    else
      block.call
    end
  end

Is this still applicable or has the syntax changed?

binarylogic commented 5 years ago

Hi @mrsweaters that shouldn't be the case. We'll take a look and see what's going on.

binarylogic commented 5 years ago

@mrsweaters you should be good to go with v3.0.1, let me know if that helps.