From the course: Polyglot Web Development

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Write functionality in Ruby

Write functionality in Ruby

From the course: Polyglot Web Development

Start my 1-month free trial

Write functionality in Ruby

- [Instructor] As with the reads, the writes in Ruby are very straightforward. Let's go over the post, we'll make the put together, and then, I'll challenge you to make a delete. First, the post. The methods, or verbs, in Ruby are exactly what you'd expect, no funny stuff. Post is post, and we're working with the quotes endpoint. Remember that the name spacing makes it so that this maps to API quotes. Just like in the random endpoint, we grab the quote with the largest index number, but this time, we're going to increment it by one to create a known good index number. We'll use the JSON function to create an object from the post body. Just like we always do we'll send back a 400 with a message if there's no content. I'll pause here a moment and point out that Ruby uses parentheses, square brackets, and braces slightly different than other languages, so pay close attention to which is which when working with it. Also, note that the if then block still stops at an end. I've found myself…

Contents