Skip to content

Instantly share code, notes, and snippets.

@aishek
Last active August 29, 2015 14:07
Show Gist options
  • Save aishek/801894fa2d4dfe1e0cca to your computer and use it in GitHub Desktop.
Save aishek/801894fa2d4dfe1e0cca to your computer and use it in GitHub Desktop.
# app/controllers/api/v1/cities/places_api.rb
class Api::V1::Cities::PlacesAPI < Api::V1::BaseAPI
namespace 'cities/:city_id' do
resource :places do
helpers ::Api::V1::CityHelper
params do
requires :city_id, :type => Integer
end
get '/' do
places = resource_city.places
present :places, places, :with => ::Api::V1::City::PlaceEntity
end
end
end
end
# app/controllers/api/v1.rb
class Api::V1 < Grape::API
format :json
content_type :json, 'application/json; charset=utf-8'
version 'v1'
mount CitiesAPI
mount Cities::PlacesAPI
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment