Skip to content

Instantly share code, notes, and snippets.

@ch1ago
Created July 20, 2012 23:08
Show Gist options
  • Save ch1ago/3153788 to your computer and use it in GitHub Desktop.
Save ch1ago/3153788 to your computer and use it in GitHub Desktop.
posts = User.last.posts_feed(params.slice(:limit, :before))
posts = V1::PostPresenter(posts)
class V1::PostPresenter < V1::BasePresenter
attr_accessor :model
def initialize(model)
self.model = model
end
def V1::PostPresenter(models)
models.map { |m| new m }
end
def as_json(options={})
{at: model.created_at, user_id: model.user_id}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment