To Lecture Notes

IT 232 -- 10/28/15

Review Exercises

  1. What is a session variable?
    Ans: A session variable stores information that persists through multiple HTTP page gets and posts.
  2. How do you store data into and retrieve data from a session variable? Ans:
    # To store:
    session[:key] = the_info
    # To retrieve:
    x = session[:key]
    
  3. How long does the information in the session variable last?
    Ans: Until all browser windows are closed or until the reset_session method is called.
  4. Where is the session variable data stored?
    Ans: In cookies on the user's harddrive.
  5. Create a Rails project named TestSession, a non-scaffold-based controller named SecretMessage, and three views that do the following:
    1. view1: stores a secret message in the session variable,
    2. view2: displays the secret message from the session variable.
    Ans: Here is the source code for the TestSession project.
  6. What is a digest?
    Ans: It is a one-way encryption algorithm. For example, the MD5 digest algorithm always encodes a message (which could be a password) in 32 bytes. A digest as also called a cryptographic hash.
  7. True or false: if a password is encrypted with MD5, the original password can be obtained if the hacker can obtain the private key.
    Ans: False. A digest is a one-way encryption algorithm. There is no private key that can decode it.
  8. Genius Question: For Project 4, how can you take all of the photos from all followers of a user and display them together or order of most recent to least recent.
    Ans: See the MiniTwitter Example.

The CustomLogin Example

The EmployeeRoster Example

Photo Model Code

Handling Validation Errors in a Non-scaffold-based Controller