A Ruby-on-Rails plugin that extends ActiveResource
When consuming server resources, you may wish to have environment specific settings (for example, have staging use a staging version of the api, and production use a production version of the api.) Additionally, you may have some service calls that take longer than a minute to run, and want to control the HTTP read_timeout variable for a service.
- Make it easier to implement environment-specific settings for ActiveResource.
- Implement the settings
open_timeoutandread_timeout.
- Install the plugin to
vendor/plugins/active_resource_config
- Copy
vendor/plugins/active_resource_config/active_resource.sample.ymltoconfig/active_resource.yml.
service_name:
development:
site: “http://localhost:3000”
prefix: “/api/”
user: ‘admin’
password: ‘shhhh’
open_timeout: 120
read_timeout: 120
production:
site: “http://host.org”
prefix: “/api/”
user: ‘admin’
password: ‘shhhh’
open_timeout: 120
read_timeout: 120
- Modify the settings to suit your needs
- In your Resource base class (if you have many models derived from a resource), include the following line at the top:
class MyResource < ActiveResource::Base
load_config :service_name
- where :service_name corresponds to the name you gave the service in active_resource.yml)
…
end
Developed out of need by Tim Harper, under Lead Media Partners
If this functionality gets accepted into the rails core ActiveResource, so be it. If not, it will continue to be available as a standalone plugin.