Week 7 "Crowdfunder" Assignment

This week we'll be creating a crowd funding web app, like Kickstarter or Indiegogo. Project creators will be able to add projects that they want people to support. Users will be able to browse the projects, and make a pledge using a form. Each funding level has a reward attached to it (e.g. Fund a project for $10 and get a free t-shirt).

Crowdfunder: seeds.rb (save to db/seeds.rb)



Best practices

  • Don’t use return, true or false unless you need to.
  • Indent your code with two spaces. Make sure your indenting is appropriate. Don't have more than one blank line between blocks of code.
  • Commit in git regularly (after completing each feature is usually good) with informative commit messages.


The data

Project model

  • name (string, required, must be more than two letters long)
  • description (text, required)

FundingLevel model

  • project (references, required)
  • reward_name (string, required, must be more than two letters long)
  • amount (integer, required, must be more than 0)

Pledge model

  • funding_level (references, required)
  • name (string, required)
  • email (email, required)
  • amount (integer, required, must be more than 0)

The relationships

Project has many Funding Levels and has many Pledges. (Don't forget to put the reverse belongs_to as well).



Routes, controllers and views

We are going to have three controllers: ProjectsController, FundingLevelsController and PledgesController.

FundingLevelsController and PledgesController should be nested under the ProjectsController. You should have URLs like /projects/1/pledges/new when you're done.

Use only: for each route/resource declaration to limit the routes to the actions you need. Use bin/rake routes to see what routes you have created.


Add some code to your app/views/layouts/application.html.erb to print out any flash messages.

Projects#index

  • link to each project's page with the most recently created on top
  • link to create a new project

Projects#new and Projects#create

  • Add a form that lets users add projects. The form should display any validation errors that occur. The form code should be in a partial.
  • Redirect back to Projects#index on success (include a flash notice).

Projects#show

  • show the project's name and description
  • list each of the project's funding levels (from cheapest to most expensive) plus a link to add a new funding level
  • list each of the project's pledges (sorted most recent to older) plus a link to add a new pledge

FundingLevels#new and FundingLevels#create

  • Add a form that lets users add new funding levels. Make sure the funding level that's created is associated with the proper project. The form should display any validation errors that occur. Redirect back to the Projects#show on success (include a flash notice). The form code should be in a partial.

Pledges#new and Pledges#create

  • Add a form that lets users add new pledge levels. Make sure the pledge that's created is associated with the proper project. The form should display any validation errors that occur. Redirect back to the Pledges#show on success (include a flash notice). The form code should be in a partial.

Projects#show, part 2

  • Include the "new pledge" on the Projects#show page, so users can enter their pledge without needing to click the "new" link.

Projects#show, part 3

  • When listing users that have already made a pledge, also show what funding level reward they will get. So if there is a $100 funding level and a $200 funding level, a user that pledges $150 will be at the first funding level.

Optional

Tired of all this unstyled HTML? Feel free to add some of these pre-written CSS frameworks (or others that you like).



Submit your work

When you are done, push your work to Github. Then email me a link to your repository on Github: alex@dunae.ca