jablko
Joined 1/15/2019
jablko said over 4 years ago on Tracking Changes on Action Text :
Hi Dave,

great episode :)

In application_controller when you assign current user you don't clear the user variable, so it  keeps the last logged user. Take a look:

irb(main):001:0> a = 'b'
=> "b"
irb(main):002:0> a = nil if false
=> nil
irb(main):003:0> a
=> "b"

Adding brackets would do the trick: CurrentScope.user = (current_user if user_signed_in?) or:

  def user_for_version
    CurrentScope.user = current_user if user_signed_in?
    yield
    CurrentScope.user = nil
  end