Project 5.0: Articl.es 2.0

Feb 7, 2011

Objective

Gain familiarity with the Rails framework.

Add a new associated model to your application, learn how to use pagination, haml and sass.

Prerequisites

You should have completed Project 4.

Requirements

You must implement the new features in your application as dictated by the Functional Requirements below.

Grading criteria (1000 points)

You must provide seed data so when I run your application, some articles are present in the database.

I must be able to pull your repository and see your project05 directory contains your app root. (eg, project05/app, project05/config, etc)

I must be able to run your migrations, insert your seed data, and run your Rails application.

This is due by 9AM on Monday, Feb 21.

Recommended Steps

In your repository, create a directory called project05. Copy your project04 files there. DO NOT use your gui to drag and drop / duplicate folders that are part of a git repo. Use the command line:

mkdir project05
cp -r project04/* project05
cp project04/.gitignore project05
git add project05
git commit -m "Adding project05 starting point. Aaaaalllll riiiiight..."

The purpose of this assignment is to see how well you grasp the way ActiveRecord abstracts object/data relationships, to introduce you to gems and plugins every Rails developer should know well, and to introduce you to something much better than ERB and CSS for markup: haml and sass.

Warning: at first, you will hate haml and sass. Eventually, you will love them. Or at least be friends with them. Trust me on this, and put your initial repulsion aside. Haven't you ever met someone you initially didn't like yet eventually became very close friends with?

Premise

"Eh..." mumbles the CEO, while peering at your screen, "There's a few things I'd like to change before we cut you that check."

"Oh boy," you think, "Another dot-bomb project. Why is it that the crazy ones are always the bosses with the money?"

"This is really, really good," says the CEO, "I really like how you DRYed out your views by placing the form fields as a partial. My cousin told me to say that, what does that mean? Was it ever wet to begin with? Anyway, I need a few more features before we can launch this for the general populace and begin our world takeover. Here are a few more requirements." He hands you a few sheets of wrinkled paper with strange stains on them. "Ooh, look at the time." he says, tapping his diamond-studded Rolex, "Gotta go!"

Additional Functional Requirements by Dudley Wilson, CEO

I'd like to change the manner in which the list of articles is displayed. Instead of a scrollable list in a table, I'd like to just, uh, paginate (is that how you say it?) the results such that ten per page are displayed. There should be some clickable links to jump to specific pages in the list as well as to move forward and backward. Sort of like this:

My sister played with the application and she was concerned about the poor normalization of the data model. She says we really need an Author model that represents a real author, and to associate each article with an author. I have no idea what she's talking about, but she drew this:

The last change requirement comes from my cousin, who thinks he knows everything about Web applications. He says that you should use haml and sass for your view work. I thought he was talking about sandwiches at first, but I quickly realized this was some technical mumbo-jumbo... so please figure it out.

Oh, and one more thing. I had some screen specifications for the Authors requirements but I think I spilled by 11AM cocktail on them. Anyway, we just need a simple UI to list, edit, create and update authors in the system. Nothing fancy here... except we need to be able to upload a picture of the author via the Author form. And when viewing an Author, you should see:

Think you can do that without a screen-by-screen specification?

Additional Requirements

Use will_paginate for the pagination.

Use paperclip for file attachments.

Learn about HAML and SASS. Convert your application's views to HAML and your stylesheets to SASS-sheets.

You must create some basic CRUD for Authors. Every author must have a name (none named Sally, thanks to the CEO).

Try your best to create a migration that takes the author_name values of your articles, creates Author instances in the database, and associates the correct Author with the relevant Article. Duplicate author names in the authors table is ok (for this project).

Hints

Use gems/plugins for common tasks such as pagination and file uploading! (see will_paginate and paperclip)

See the links and topics in Unit 5.