CS142 Project #4: Migrations and Models

In this project you will use Rails to create the beginnings of a photo-sharing Web site. For this project, the Web site will display pre-entered information in the database. In future projects you will add additional features, such as the ability to add new photos and to tag photos with the names of users.

Setup

Create a Rails application for this project by invoking the following command:

rails project4

This will create a directory project4 that contains a skeleton for the project. Your solutions for the problems below should be implemented in this project.

Problem 1: Use Migrations to Create the Database (10 points)

Problem 2: Create the Application (10 points)

Create a controller and views that implement two URLs. The first URL is /pics/allUsers. When this URL is referenced your application must return a Web page that displays a list of all users in the database. The user names must be links: clicking on a user name displays the photos for that user, as described below.

The second URL supported by your application has the form /pics/user/id, where id is the database identifier for a particular user. When this URL is referenced your application must return a web page displaying all of the photos belonging to that user. For each photo you must display the photo itself, the creation time for the photo, and all of the comments for that photo. For each comment you must display the time when the comment was created, the name of the user who created the comment, and the text of the comment. The creator for each comment should be a link that can be clicked to switch to the photos page for that user.

Although you don't need to spend a lot of time on the appearance of the pages you generate, they should be neat and understandable. They should have meaningful titles, and the information layout should be clean (e.g., it should be clear which photo each comment applies to). Use the personalized layout you created for the last project.

Deliverables

Use the standard class submission mechanism to submit the entire application (everything in the project4 directory). As usual, your generated HTML must validate as proper XHTML (you do not need to validate your CSS for this project).