rails/rails — pull request #9699 by rubys (2013-03-13 12:26:55+00:00)
Title: Add support for generate scaffold password:digest

has_secure_password is a useful feature that presents "virtual" password and password_confirmation attributes on creation and update backed by a password_digest attribute in the database. Getting the migration, model, views, tests, and fixtures correct is needlessly complicated. This change enables application developers to specify password:digest on a generate scaffold command. Doing so:

* adds password_digest attribute to the migration
* adds has_secure_password to the model
* adds password and password_confirmation password_fields to _form.html
* adds password_digest to index.html and show.html
* adds password and password_confirmation to the controller
* adds unencrypted password and password_confirmation to the controller test
* adds encrypted password_digest to the fixture

The following tests have been run and pass successfully:

TEST_DIR=generators bundle exec rake test

Additionally, the __unmodified__ Agile Web Development with Rails tests have been run (i.e., they haven't been updated to use this new option), and I've verified that absolutely no change to any of the generated artefacts results by this change.

Not done yet: changelog, new tests, jbuilder, and updating AWDwR. I'd like to get feedback on the approach before proceeding to nail down the details. @steveklabnik, @jeremy, @carlosantoniodasilva