Thursday, March 13, 2014

Week 6 Day 4: A Recipe for Success

Major Activities of the Day: We started out with a review of yesterday's exercises in making forms.  To be honest, I kind of zoned out, because I had done it already.  I need to start paying more attention, even when I have the excuse that "I know how to do it already!" because there is often a better way I'm not aware of.  This is especially true in Rails where the most obvious way isn't always the best.

We then spent a few hours working (individually/in groups) on a lab where we created a website that associates Recipes and Ingredients through a join table.  The point was to figure out how to create forms that will associate items using a nested params hash including hashes and arrays.  The major technical difficulty was creating checkboxes, since checkboxes are just super-hard to deal with in form creation.  But ultimately everything was figured out, and the form for my app now lets you create a new recipe with any existing ingredients (in any particular quantity) and/or add a new ingredient.  You can also view recipes by included ingredients.

After working on this for a few hours, we got together and had a lecture where Avi ran through the lab.  There were a number of occasions where he went back and forth about using high-level Rails methods rather than dropping down a level and coding HTML or using simpler Rails methods, but ultimately students convinced him to go with the high-level Rails method for creating checkboxes for the ingredients, and it worked pretty well!

Today was also a NYC on Rails meetup.  All the projects were pretty cool.  The grand finale was Wontae Yang's project using JRuby and NYC government-provided data to visualize the movement of subway trains and buses throughout the day.  It was really amazing to watch how, as night turns to morning, the city comes alive with buses and trains, and their tracks form the shape of the city (you can see a space for Central Park!).  Check out a Vine video of it here.

Skills developed: Rails forms (but we're getting really good at it!) for objects with complex relationships

No comments:

Post a Comment