Simple Rails shopping cart system assuming one user.
- In main directory, run bundle install.
- Start postgresql server.
- Setup database and populate with included seeds file.
- In terminal, start local server with rails s command.
- Test API.
Testing can be done with curl in the terminal. For easier testing, CSRF protection is disabled in application_controller.rb.
curl http://localhost:3000/api/products/
curl http://localhost:3000/api/shopping_cart
Change product_id and/or quantity
curl -H "Content-Type: application/json" -d '{"shopping_cart_item": {"product_id": 9, "quantity": 2}}' http://localhost:3000/api/order_items
Change quantity and item primary key at end of URL (correct IDs can be seen when viewing cart).
curl -X PATCH -H "Content-Type: application/json" -d '{"shopping_cart_item": {"quantity": 4}}' http://localhost:3000/api/order_items/1
Change item primary key at end of URL (correct IDs can be seen when viewing cart).
curl -X DELETE http://localhost:3000/api/order_items/1
curl -X PATCH -H "Content-Type: application/json" -d '{"shopping_cart": {"status": "complete"}}' http://localhost:3000/api/shopping_cart/
curl -X DELETE http://localhost:3000/api/shopping_cart/
curl http://localhost:3000/api/orders
Change order primary key at end of URL (correct IDs can be seen when viewing orders)