Forum: Ruby on Rails class attributes and thread safety

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Paul Stadig (Guest)
on 2006-04-12 16:00
Are class attributes thread safe?  For instance, the userstamp plugin
creates a User.current_user attribute and then it aliases the
ActiveRecard create and update methods to write created_by and
updated_by attributes using the value of User.current_user.  For some
reason I can imagine a case where multiple users are logged in at the
same time and saving objects, and the value of User.current_user would
be indeterminate.

It could be that I'm applying too much "Javathink" because this kind of
class attribute would be a problem in Java (of course its more
complicated with class loaders and such).  But I can't help but think
that ruby may have some difficulty in this situation, too.

The answer to this question may depend upon what web server is used
and/or how the rails app is being served.  Is there a single,
straight-up answer to this question?


Paul Stadig
This topic is locked and can not be replied to.