I have a Session class to store the currently logged user. It's something like that:
class Session
attr_reader :user, :ip, :gef
attr_accessor :branchid
def initialize(user, ip, gef=nil)
(...)
end
(...)
end
Then I have a controller method to change this branchid, so the user can access different things. The logged_user is a Session class that's being set as a helper method on the ApplicationController:
class ApplicationController < ActionController::Base
helper_method :logged_user
(...)
def some_method_that_sets_logged_user_before_calling_change_branch
self.logged_user = Session.new params[:user], params[:ip]
end
def change_branch
logged_user.branchid = params[:branchid]
redirect_to root_path
end
end
That worked perfectly when I was using Ruby 1.9.3 with Rails 3.2. I'm now upgrading Ruby to 2.1.4, and this seems to have stopped working. I put a byebug
in the middle of the change_branch method to see what's going on, and trying to alter logged_user
directly via the console simply doesn't work.
When I type (in the server console, while debugging)
self.logged_user.branchid = 31
and then call
self.logged_user.branchid
it will return the old value, not 31.
Did anything in Ruby 2.0 or 2.1 change so this won't work anymore?