Skip to content

Instantly share code, notes, and snippets.

@paulspringett
Created June 9, 2011 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulspringett/1016532 to your computer and use it in GitHub Desktop.
Save paulspringett/1016532 to your computer and use it in GitHub Desktop.
Streamsend ActiveResource fix
class Streamsend::Blast < ActiveResource::Base
self.site = "https://app.streamsend.com/"
self.user = "{login_id}"
self.password = "{key}"
self.element_name = "blast"
private
# fix because streamsend rarely includes the type="array" attribute
def self.instantiate_collection(collection, prefix_options = {})
collection = collection[self.element_name] if collection.instance_of?(Hash)
collection.collect! { |record| instantiate_record(record, prefix_options) }
end
end
@paulspringett
Copy link
Author

Line 12 is the fix

@paulspringett
Copy link
Author

But you'd obviously need to drop in lines 8-14 into any ActiveResource model, or create a Base model for all your AR models to inherit from, and put it in that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment