Welcome to my API homework app. Built upon this amazing RESTful API blog post. This API is versioned and set up with json:api standards using rabl.
I've been getting a couple questions about how to get this setup and running, below are some dependancies you'll need:
The version isn't a big deal, just prefix your requests with /v1/, but the subdomain can be tricky for beginners. You'll need to run a service like Pow to use subdomains in development. You can pair this with the ruby gem Powder for some really awesome times :)
After you have these set up, you can successfully go to a url like api.rest-api.dev/v1/dreams
There are also some really basic api tests written from codeschools rest api course, try them out with rake test
User :name, :age, :city, :state
Dream :date, :category, :description, :user_idviews/api/v1/dreams & views/api/v1/users contain a index and show
controllers/api/v1/base_controller contains the most logic, see private method comments. These will set and get the resource names as needed for each controller.
Kaminari has a default page size of 25, to override this pass in a page and/or a page_size paramater like the following:
http://api.rest-api.dev/v1/dreams.json?page=1&page_size=10
Each controller has permitted query params, by default they are all allowed:
http://api.rest-api.dev/v1/dreams.json?user_id=5&category=Nightmare
HTTParty.get 'http://api.rest-api.dev/v1/users.json'HTTParty.post('http://api.rest-api.dev/v1/users', body: { user: {name: "Json", age: "22", city: "Plainsville", state: "NV"} })HTTParty.patch('http://api.rest-api.dev/v1/users/4', body: { user: {name: "Jason"} })HTTParty.delete 'http://api.rest-api.dev/v1/users/4'