On Sun, Dec 13, 2009 at 4:40 PM, Yehuda Katz <wyc...@gmail.com> wrote:
> Long-term, we want to try to get away from using global state like
> this as much as possible, but fixing it can sometimes open a thorny
> can of worms. Koz's solution, paired with a mutex or thread-local (for
> threadsafe scenarios) is a good workaround for now.

What's the can of worms?  Just thread safety?

How about this approach (suggested by Adam Milligan):

class ActiveResource::Base
  def self.connect(current_site)
    old_site = site
    begin
      self.site = current_site
      connection(:refresh)
      yield
    ensure
      self.site = old_site
    end
  end
end

This would also need to be made threadsafe, but isn't it essentially
the same thing Koz suggested, without a dependency on DelayedJob?

-- Chad

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to rubyonrails-c...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.


Reply via email to