11 May '13, 5am
AwesomeResource via @pivotallabs
I’ve had it . I’ve had the misfortune to need ActiveResource (an http client library for giving you an ActiveRecord-like API for interacting with restful services) off and on for several years now. Even when it’s worked, it’s never worked well. Let’s start with the way you configure it. You know how you can use a database.yml file to specify your ActiveRecord connections for different environments? Wouldn’t you expect ActiveResource to work similarly? I mean, it seems unlikely that you’d actually connect to the exact same server endpoint in test, development, and production, right? Too bad. ActiveResource gives you a single way to set a model’s “site”: an attr_writer on the model’s singleton: class MyModel < ActiveResource::Base self.site = ‘http://some-server.com’ end That global state isn’t a good sign. Even after you hack in your own environment-specific connection code...