Rails class attribute (attr_accessor) not being changed at all using Ruby 2.1.4 -
There is a session class to log in to my current session. It is something like this:
class session attr_reader: user ,: ip,: gef attr_accessor: branchid def initialize (user, ip, gef = nil) (...) end (...) end
Then I have a controlling method to change this branch, so the user can access a variety of things log-in is a session class which is being set on an ApplicationController as a helpful method:
< Pre> class Applic AtionController & lt; ActionController :: Base helper_method: [: user] logged_user (...) def self.logged_user = Session.new parameter some_method_that_sets_logged_user_before_calling_change_branch, parameter [: ip] end def change_branch log_user.branchid = params [: branchid] root_path end end This worked perfectly when I was using Ruby 1.9.3 with Rail 3.2. Now I'm upgrading Ruby to 2.1.4, and it has stopped working. Trying to change the byebug
in the middle of the change_branch method to see what I'm doing, and trying to change directly logged_user
through the console just work does not do.
When I type (in server console, when debugging)
self.logged_user.branchid = 31
and Then call
self.logged_user.branchid
This old value will return, not 31.
Anything changed to Ruby 2.0 or 2.1, so it won 'do not work anymore?
Comments
Post a Comment