Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

evaluate ActiveResource::Base.site at runtime

#6582

I want to write an API client app for our REST API. The app serving the API publicizes it over different subdomains for different clients, i.e.:
clientA.myapp.org/api/people
clientB.myapp.org/api/people
The client app must be able to query any client depending on the user logged in to the client app.

The set of possible clients is not static and can change any time.

ActiveResource::Base.site is usually set at app startup time, which makes no sense for me, because I don't know to which client the first user accessing my client app belongs to yet.
Resetting site with every request is not a solution, because I think it's not thread safe, since site is a class variable and shared across all parallel requests.

The solution is imho to make site not a value, but either a function or an object that is capable of calculating the site at runtime.

I hope this makes any sense to you.

Reported by Axel Tetzlaff · March 15th, 2011 @ 11:32 AM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. booamd
    booamd

    Theirs is a living, breathing, ongoing phenomenon spanning more than three centuries.(http://www.bagsairs.com)

    March 15th, 2011 @ 12:07 PM

  2. Axel Tetzlaff