Skip to content

Instantly share code, notes, and snippets.

@g1na1011
g1na1011 / c1wk1_quiz.md
Last active December 23, 2015 01:09
Below are the answers to our first week's quiz from Course 1 of Tealeaf Academy

Week 1 Quiz

  1. What is the value of a after the below code is executed?

    a = 1
    b = a
    b = 3
Answer: `a = 1` after the code is executed. 
  1. What's the difference between an Array and a Hash?
@g1na1011
g1na1011 / c1wk2_quiz.md
Last active December 23, 2015 03:29
Below are the answers to our second week's quiz from Course 1 of Tealeaf Academy

Week 2 Quiz

  1. Name what each of the below is:
  a = 1 
  # => ex. a is a local variable, and is a Fixnum object with value 1
  
  @a = 2 
  # => @a is an instance variable, and is a Fixnum object with value 2
  
user = User.new 
@g1na1011
g1na1011 / c2wk1rails_quiz.md
Last active December 24, 2015 23:19
Below are the answers to our first week's quiz from Course 2 of Tealeaf Academy (regarding associations, relational database, primary vs. foreign keys, mass assignment, etc.).

Rails Week 1 Quiz

  1. Why do they call it a relational database?

    We call it a relational database, because the tables within the database are associated with each other. This association can be created with primary/foreign keys and various syntax.

  2. What is SQL?

    SQL stands for "Sequence Query Language" and it is used to manage the operations of a relational database.

  3. There are two predominant views into a relational database. What are they, and how are they different?

    The two predominant views are the data and schema views. Data view displays like a spreadsheet, with the table columns at the top and rows of data per each object instance. A schema view shows us the column names and the value type of each column.

@g1na1011
g1na1011 / c2wk2rails_quiz.md
Last active December 25, 2015 06:29
Below are the answers to our second week's Rails quiz from Course 2 of Tealeaf Academy (regarding routes, helpers, partials, validation, model backed vs. non-model backed forms, etc.).

Rails Week 2 Quiz

  1. Name all the 7 (or 8) routes exposed by the resources keyword in the routes.rb file. Also name the 4 named routes, and how the request is routed to the controller/action.
  # Assuming you are getting resources :posts
  
  $ rake routes
  
  get '/posts', to: posts#index                => posts_path
  get '/posts/object', to: posts#show          => post_path(object)
  get '/posts/object/edit', to: posts#edit => edit_post_path(object)
@g1na1011
g1na1011 / c2wk3rails_quiz.md
Last active December 26, 2015 04:39
Below are the answers to our third week's Rails quiz from Course 2 of Tealeaf Academy (regarding passwords, authentication, model layers, polymorphic associations, rendering vs. redirecting, etc.).

Rails Week 3 Quiz

  1. What's the difference between rendering and redirecting? What's the impact with regards to instance variables, view templates?

    Rendering displays a view template that accesses the instance variables available in that action. Therefore, instance variables must be declared in that action before the render will work. Redirecting will send a new request to the browser based on the route path that was provided. In this case, the instance variables in that action are not related to the redirected view.

  2. If I need to display a message on the view template, and I'm redirecting, what's the easiest way to accomplish this?

    You can use flash, which saves the message with a session. The message will be displayed on your next action and will be removed after that.