day 123 — code 365

Wed 13 Apr 2016

WDI Week 8 (Day 38)

What we did today:

  1. Backbone / Rails — Burning Airlines
  2. Talk — Computer Security
  3. Field trip — Prismatic (web development / product design agency)


We can make Rails variables accessible to Backbone! If we place @user inside a script tag in our html.erb file:

app.current_user = <%= @user.to_json.html_safe %>;

This creates a property inside our app object that stores @user, making it accessible to Backbone!

An efficient approach to making a seat reservation is by going through the Reservation Model. By assigning a user_id, flight_id and seat_id to a reservation (a row in that DB table), through the magic of Active Record associations, Rails will automatically associate a user with a flight!

We have to whitelist user_id before Rails will allow it to be saved to the DB. This is because all save methods perform a HTTP POST request to Rails, which ends up being processed by our create action, which only accepts reservation_params.

When we are working within a View model, if we specify events (DOM listeners), these will only work for elements that are children of the specified el / tagName.

A handy Underscore method: This will get the 1st flight object in the array! (instead of going by (and needing to get) ID’s, like

Burning Airlines

This was a good day for us! We made solid progress with the functionality of our app, and we improved in terms of collaborating effectively together. This was probably a combination of having a basic working framework to our app, a better understanding of the innards of git, and being able to delegate sub-tasks more specifically — probably because we are now more at the stage where there are distinct issues / features that need to be done.

Exciting day — thanks for stopping by!