Class attributes and thread safety

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs