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.
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.
User
and its
associated database table, with the following attributes:
id | Primary key for this user. |
first_name | First name of the user. |
last_name | Last name of the user. |
project4
directory and
invoke the following command:
ruby script/generate model user
Photo
and its associated database table, with the following attributes:
id | Primary key for this photo. |
user_id | Identifier for the user who created the photo. |
date_time | The date and time when the photo was added to the database. |
file_name | Name of a file containing
the actual photo (in the directory
project4/public/images ).
|
Comment
and its associated database table,
with the following attributes:
id | Primary key for this comment. |
photo_id | Identifier for the photo to which this comment belongs. |
user_id | Identifier for the user who created the comment. |
date_time | The date and time when the comment was created. |
comment | The text of the comment. |
ruby script/generate migration load_data
project4/public/images
.
rake db:migrate
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.
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).