I am stuck on how to set the site variable to ActiveResource at runtime, I read this post which explains how to do the same
http://blog.rubybestpractices.com/posts/gregory/rails_modularity_1.html
But the only problem there is the mapping from service name to url is predefined. I开发者_如何转开发n my case its the same service except in different domain and return identical results.
domain1.mydomain.com
domain2.mydomain.com
This active resource belongs to another active record model and which domain to access depends on the attributes active record model retrieves from database. Is there a way to do this?
Thanks in advance.
Surprisingly, it's pretty simple:
klass.site = "http://domain.com"
#make request
klass.site = "http://domain2.com
精彩评论