Explore a Sinatra example, library use, server setup, MongoDB interaction, and syntax. Get a walkthrough of the GET command for the quote list and individual quote, then create a "random" endpoint to get a random quote.
- [Instructor] Okay, let's get started with Ruby now.…We're using the Mongoid driver which has…a simple mongoid.yml file in the same directory.…Mongoid is much more object oriented than the Mongo driver…and both are supported by the MongoDB team.…Let's take a look at the main program.…As always, we need to install the needed libraries…to get the system ready.…We're using Sinatra for the base web server…and the sinatra/namespace library will allow us…to make the paths easier to work with.…Next is the Mongoid library,…and then the JSON extension library giving us…a to_json method to use for return values.…
One note, Ruby has require for modules that want importing,…and then there's also include.…Require runs the specified file to access the modules…and include pulls the package into the current context…so that the methods from the module can be used.…Here in the Quote definition,…you can see a structure common in Ruby.…The package being included is Mongoid::Document…which means that it's inheriting from the document object…
- Why become a polyglot programmer?
- Exploring Node.js, Python, Perl, and Ruby code
- Building on prior knowledge to learn new programming languages
- Learning API read and write functionality in Node.js, Python, Perl, and Ruby
- Implementing API functionality in Node.js, Python, Perl, and Ruby
Skill Level Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
1. Becoming a Polyglot
Next steps1m 19s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.