Skip to content

Vending Machine is a basic interface that demonstrates All Aboard, a light-weight web application framework.

Notifications You must be signed in to change notification settings

tomerovadia/VendingMachine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vending Machine

Live

Overview

Vending Machine is a basic interface that demonstrates All Aboard, a light-weight web application framework.

It renders a collection of items, each including a name, image, price and id.

Users can interact with the vending machine as a customer (default) or operator. A button at the top allows them to toggle between roles.

Operators can add or remove items. Customers can purchase items.

This app persists data using a cookie stored in the user's browser. This utilizes the sesssion functionality provided by All Aboard. Items as well as mode (customer or operator) are persisted.

Controllers

Vending Machine manages two resources: Vending Machines and Items. Only one Vending Machine is instantiated per session of the app, and this instance stores multiple instances of Items. The app has a VendingMachineController and ItemsController to handle HTTP requests regarding these resources.

Routes

Vending Machine utilizes four routes (declared in routes.rb):

  • get Regexp.new("^/$"), VendingMachinesController, :show
    • Renders the vending machine homepage
    • Called when visiting the root path
  • delete Regexp.new("^/vending-machines$"), VendingMachinesController, :destroy
    • sets the session cookie to nil, thus reseting the vending machine to its default state
    • called by the Reset button
  • post Regexp.new("^/items$"), ItemsController, :create * Creates a new item * Called by the add items form available while in operator mode
  • delete Regexp.new("^/items/(?<id>.+)$"), ItemsController, :destroy
    • Removes an item
    • Called by either the Purchase button (customer mode) or Remove button (operator mode)

About

Vending Machine is a basic interface that demonstrates All Aboard, a light-weight web application framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published