Skip to content

Instantly share code, notes, and snippets.

@javifr
Created June 16, 2014 15:25
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 javifr/fd9037c0e26c607b9d32 to your computer and use it in GitHub Desktop.
Save javifr/fd9037c0e26c607b9d32 to your computer and use it in GitHub Desktop.
# Normal locations fetching
# page_url IS http://localhost:3000/api/v1/locations?page=1
# Nearby locations fetching
# page_url SHOULD BE http://localhost:3000/api/v1/locations?latitude=41.406410&longitude=2.191986&distance=10&near=true?page=1
# page_url IS http://localhost:3000/api/v1/locations?page=1
# How can i maintain this params?
# ?latitude=41.406410&longitude=2.191986&distance=10&near=true?
module LocationsRepresenter
include Roar::Representer::JSON::HAL
include PaginationRepresenter
collection :items, :extend => LocationRepresenter, embedded: true
def page_url(*args)
v1_locations_url(*args)
end
end
@apotonick
Copy link

The representer can't access params, this is a horrible global concept from Rails. Pass in what you need: https://github.com/apotonick/representable#passing-options

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