Created
November 7, 2012 23:41
-
-
Save nsanta/4035407 to your computer and use it in GitHub Desktop.
ActiveResource is dead, long live ActiveResource 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GET /posts.json delivers following response body: | |
# { | |
# posts: [ | |
# { | |
# title: "ActiveResource now has associations", | |
# body: "Lorem Ipsum" | |
# } | |
# {...} | |
# ] | |
# next_page: "/posts.json?page=2" | |
# } | |
class Post < ActiveResource::Base | |
self.site = "http://example.com" | |
self.collection_parser = PostParser | |
end | |
class PostCollection < ActiveResource::Collection | |
attr_accessor :next_page | |
def initialize(parsed = {}) | |
@elements = parsed['posts'] | |
@next_page = parsed['next_page'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess you mean in line #15
self.collection_parser = PostCollection
Great Post BTW