Assignment 3
Creating non-scaffolded controllers and views
Due Friday April 20 before 11:30pm

Overview

For this project, you will add a new controller and view to a scaffolded application. This controller and view will present a summary report of the database contents for your application.

The assignment addresses the following goals:

  1. Adding a method to the model class
  2. Creating a controller and view
  3. Assigning instance variables in the controller
  4. Presenting dynamic content in a view
  5. Using CSS to format a page
  6. Matching a route to a controller and action

Scaffold creation

This project requires the use of a scaffolded application. You may want to use the same application from the last week.

New model method

Create a new model method and add it to your model file. This method (perhaps called 'description') returns a summary description of an instance belonging to the model. We'll go over an example in class.

New controller and view

Create a new controller called 'report' and a view called 'summary'. This step can be completed with one command:

rails generate controller report summary

Check the routes.rb file (in the config folder) and verify that a new route has been created. You can also run the application to see if the dummy page is working. The URL path is this:

hostname/report/summary

View presentation

Write code to the new controller and view so that it presents the following information:

  • A statement indicating the number of records in the database table
  • A listing of records in a specific order using the new class method you created (e.g. 'description')
  • A statement indicating whether there are any records meeting a specific condition

You are strongly encouraged to add additional information to your view. Examples might include the date of when the last record was added or a listing showing records that meet a specific condition.

Finally, use CSS to provide some formatting to your view.

Report

Using any word processor, write a short summary document that describes your efforts for this assignment. The summary document should include the following:

  • A brief overview of your scaffolded application
  • The addition of your new model method
  • What your new controller and view do

Submission

Place the summary document in your rails application folder. Zip up the folder. Submit the zip file using D2L.

Grading

This project is worth 20 points:

  • 5 points --- a clear, well written summary document
  • 5 points --- working model method
  • 5 points --- working controller and view presents required information
  • 5 points --- well formatted view using some CSS

Submissions are eligible for partial credit. Always submit an assignment even if it is not complete.