Forum: Rails deployment ActiveResource How to set site at runtime?

317c16974a5a08826bcc254dad806dff?d=identicon&s=25 James West (jamesw)
on 2009-09-06 23:04
I have a number of ActiveResource classes that I won't know the site for
until runtime.

The current definition for one of these resources looks like this

class ResourceSiteDetail < ActiveResource
  self.element_name = "site_detail"
  self.site = "https://somesubdomain.mydomain.com"
  self.user = XXXX
  self.password = XXXXXX
  self.timeout = 10
end

I need to set the site url at runtime rather than at class definition
time
Is it possible to pass the url in as a parameter?

Ideally I would like to do something like

@sd = ResourceSiteDetail.new("fred")

and have in the class definition look like this

class ResourceSiteDetail < ActiveResource
  self.element_name = "site_detail"
  self.site = "https://#{site_name}.mydomain.com" #How do I get
site_name passed in as a parameter?
  self.user = XXXX
  self.password = XXXXXX
  self.timeout = 10
end
But I am totally stumped as to how to achieve this.
Any ideas at all would be greatly appreciated
This topic is locked and can not be replied to.