Skip to content

timcharper/active_resource_config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Active Resource Config

A Ruby-on-Rails plugin that extends ActiveResource

Overview

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.

Features Implemented by Plugin

  • Make it easier to implement environment-specific settings for ActiveResource.
  • Implement the settings open_timeout and read_timeout.

Usage

  • Install the plugin to vendor/plugins/active_resource_config
  • Copy vendor/plugins/active_resource_config/active_resource.sample.yml to config/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

  1. where :service_name corresponds to the name you gave the service in active_resource.yml)

    end

Credits

Developed out of need by Tim Harper, under Lead Media Partners

Conclusion

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.

About

Environment-specific configuration for active-record, stored in config/active_resource.yml. Adds some more config parameters.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages