= Boilerplate Generator

Boilerplate is a generator for new Rails projects. It automatically creates a
working account system for user login and registration, a basic layout, some
named routes, and (of course) a comprehensive suite of tests.

If you have any questions, comments, criticisms, or unmelted chocolate
sundaes, please contact me via electronic mail. My address is
[email protected]

== Why?

Because I get tired of creating the same basic things each time I start a new
project. Steeped in frustration, I extracted all the preliminary code from last
project I created and packaged it up for posterity.

== What's included?

Nothing fancy, really. That's the whole idea: no smoke, no mirrors. Just simple
code that's easy to modify and/or extend.

models
A User model with support for hashed (and salted) passwords, all the necessary
validations, and an authenticate class method. Take a look at
db/migrate/###_create_users.rb if you want to see the schema definition

views
Views for login and signup, plus a simple xhtml layout that includes
the default javascript libraries

controllers
An account controller with index, login, signup, and logout actions; a
modified application_controller that mixes in the AuthenticationSystem module.
The current_user method returns a User object provided a User with an id equal
to session[:user] can be found; the authenticate method redirects to the
login_url if current_user returns false

routes
Named routes for signup_url, login_url, and logout_url and a resource route
for users (map.resource :user)

migrations
A migration to create the Users table

tests
A comprehensive suite of tests covering the User model, and the all the
Account and User actions

== Test Specs

Account controller should:
* login user and redirect
* not login invalid user
* logout and redirect
* remember login if remember me is set
* not remember login if remember me is not set
* delete token on logout
* login automatically from cookie
* fail cookie login with expired cookie
* fail cookie login with invalid cookie

User controller should:
* create user
* require login on create
* require unique login on create
* require password on create
* require password confirmation on create
* require email on create
* require valid email on create
* require authentication for show
* require authentication for edit
* require authentication for update
* accept http basic authentication

User should:
* create user
* update user
* destroy user
* accept valid emails
* not allow invalid emails
* not allow spaces or dots in login
* reset password
* not rehash password when unchanged
* authenticate user
* set remember token
* unset remember token
* remember login for one week
* remember login until one week from now
* remember login for default two weeks

== Usage

Boilerplate is intended to be used on a fresh Rails application. You're free to
use it on an app with code in it already; it will prompt you before it tries
to overwrite any existing files.

To generate the boilerplate code for your application, use the generate script:

$ ./script/generate boilerplate

Assuming you have the databases set up for your application, run the migration
script which will create the User table:

$ rake db:migrate

Run the test suite to make sure everything is kosher:

$ rake test

== Generated files

The following files are generated:

+-- app
| |-- controllers
| | |-- account_controller.rb
| | |-- user_controller.rb
| | `-- application.rb
| |-- models
| | `-- user.rb
| `-- views
| |-- account
| | |-- index.html.erb
| | |-- login.html.erb
| | `-- signup.html.erb
| |-- user
| | |-- _form.html.erb
| | |-- edit.html.erb
| | |-- show.html.erb
| | `-- new.html.erb
| `-- layouts
| `-- application.html.erb
|-- config
| `-- routes.rb
|-- db
| `-- migrate
| `-- ###_create_users.rb
|-- lib
| `-- authentication_system.rb
`-- test
|-- fixtures
| `-- users.yml
|-- functional
| |-- user_controller_test.rb
| `-- account_controller_test.rb
|-- test_helper.rb
`-- unit
`-- user_test.rb


---
Copyright (c) 2007 Jeffrey Allan Hardy, released under the MIT license