To Lecture Notes

IT 232 -- 10/5/15

Review Exercises

  1. Here is the correct validation that uses a regular expression to check the input:
    validates :phone, format: { with: /\A\d{3}\/\d{3}-\d{4}\Z/ }
    Write and test a validation that checks a part number which has the format
    (A|B|C)\d\d\d-(D|E|F)\d\d\d\d\d
    Ans:
    validates :part_num, format: { with /\A(A|B|C)\d{3}-(D|E|F)\d{5}\Z/ }
    
  2. What do these acronymns mean?
    DRY  CoC  CRUD  HTTP  REST
    
    Ans: DRY: Don't Repeat Yourself; CoC: Convention over Configuration; CRUD: The standard database operations Create, Read, Update, Destroy; HTTP: Hypertest Transfer Protocol; REST: Representation State Transfer.
  3. What are some HTTP methods (also called verbs)?
    Ans: GET HEAD POST PUT DELETE
  4. Try getting a webpage using old fashioned HTTP:
    telnet condor.depaul.edu 80
    GET /sjost/ HTTP
    
  5. What is the difference between the HTTP verbs GET and POST for sending a form back to the server?
  6. What is the difference between FormTagHelper and FormTag methods?
    Ans: When sending a form back to the server, GET embeds the data in the URL to send it, for example:
    http://localhost:3000/client_server/server?utf8=%E2%9C%93 ⇓
        &name=Alice&gender=F&age=11&commit=Submit+Info+to+Server
    
  7. The Rails BlogPostSite Example project contains source code errors. There are about 5 errors for the index and show views and the _form.html.erb file.  There are about 2 errors on the new and edit views. Find the errors.
  8. The TemperatureConverter1 Example project contains source code errors (about 5 errors per page). Find the errors.
  9. Modify the Temperature1 project to:
    1. include another textfield on the input view for entering a name,
    2. enter the name, the Celsius temperature, and the Fahrenheit temperature in a database table with model name TempConvertRecord

Project 3

Many-to-many Relationships