To Lecture Notes

IT 231 -- 9/13/12

 

Review Questions

  1. How do you open a Command Prompt Window?
    Ans: Start >> All Programs >> Accessories >> Command Prompt.
    You can also enter Start and type cmd in the box "Search programs and files."
     
  2. What are the Command Prompt DOS commands that do the following?
    1. Delete a file   Ans: del
    2. Create a new folder.   Ans: mkdir
    3. List all files in a folder.   Ans: dir
    4. Move to the parent folder.   Ans: cd ..
    5. Move to a child folder.   Ans: cd foldername
    6. Move to the root folder on the current drive.   Ans: cd \
    7. Change to a different drive.   Ans: e: if you want to change to drive e.
    8. Show the contents of a file on the screen.   Ans: type filename

  3. List the steps for creating and viewing a Rails project.   Ans:
    1. Use the rails command to generate the Rails scripts.
    2. cd into the newly created Rails project folder.
    3. Use rails generate controller to create the controller and views.
    4. Start the server with rails server.
    5. View the project on localhost:3000.

  4. List some of the folders created for a Rails project.
    Ans: Folders that we have used so far are app/controllers, app/views, app/assets/images, app/assets/stylesheets. Here is a list of Rails folders.
     
  5. What are views? Where are they located?
    Ans: Views are HTML pages that are generated by Rails. A view is created by combining an .html.erb Rails view with a layout to produce the generated page.
     
  6. What is the difference between a view and a layout in Ruby on Rails?
    Ans: The view is the content of the page that is normally between the body tags. The layout is everything else on the HTML page.
     
  7. Where are images and CSS stylesheets placed in a Rails project?
    Ans: In app/assets/images and app/assets/stylesheets, respectively.
     
  8. What is the file extension for view files?
    Ans: .html.erb, where erb means Embedded Ruby.
     
  9. What is WEBrick?
    Ans: A localhost server for Rails.
     
  10. What is one of the disadvantages of WEBrick?
    Ans: It is slow. Its source code is also completely undocumented, which gives it a bad reputation for some developers.
     
  11. What is a method in object oriented programming?
    Ans: It is code that can be called by an object. Methods are also called functions, subroutines, or procedures.

 

The Anatomy of a Rails URL

 

Embedded Ruby and Some Helper Functions

 

Examples

 

Project 1

 

Submitting Projects