Skip to content

Instantly share code, notes, and snippets.

@danneu
Forked from anonymous/gist:4050880
Created November 10, 2012 12:30
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 danneu/4050944 to your computer and use it in GitHub Desktop.
Save danneu/4050944 to your computer and use it in GitHub Desktop.
# config/routes.rb
namespace :api, defaults: {format: "json"} do
namespace :v1 do
resources :wines
end
end
# wines_controller
class WinesController
def index
limit = params[:limit] || nil
@wines = Wine.limit(limit)
end
end
api/v1/wines?limit=10 returns 10 wines
api/v1/wines returns ALL wines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment