Wednesday, February 26, 2014

Week 4 Day 3: Singing the Sweet Songs of Sinatra

Major activities of the day: We started off today with a quick assignment to make sure we understand how a status code is returned by a server.  The morning lecture covered ActiveRecord associations, dealing with all the ways ActiveRecord methods can be used to generate, save, and access objects.  We followed this up with a lab where we had to run migrations and create models for artists, songs, and genres, where each song had an artist and a genre, and the artists and genres were associated with each other through the songs.

In the afternoon, we were introduced to Sinatra, and put together a simple message-posting app.  The lecture clarified how Sinatra builds on the standard Rack framework to let you create simple websites quickly and easily.

Fun note: I found an even better way today of doing my person object.  It already exists in Ruby!  It's called an OpenStruct, and it's really cool.  Here's the code:


require 'ostruct'
person = OpenStruct.new


And you're done!  The documentation is online at http://www.ruby-doc.org/stdlib/libdoc/ostruct/rdoc/OpenStruct.html

Skills developed: ActiveRecord associations, Sinatra

No comments:

Post a Comment