diff options
author | Sam Ruby <rubys@intertwingly.net> | 2013-03-13 08:08:56 -0400 |
---|---|---|
committer | Sam Ruby <rubys@intertwingly.net> | 2013-03-13 16:06:33 -0400 |
commit | 3008994d1e29b7e59a64bf0a03b5408a2946db25 (patch) | |
tree | 34195fc32c9188a17820c3ba4833ba26053ab353 /activerecord/lib/rails | |
parent | cd9f7508df9485ea7ec66d0172c1d6bcfe7ed5a8 (diff) | |
download | rails-3008994d1e29b7e59a64bf0a03b5408a2946db25.tar.gz rails-3008994d1e29b7e59a64bf0a03b5408a2946db25.tar.bz2 rails-3008994d1e29b7e59a64bf0a03b5408a2946db25.zip |
Add support for generate scaffold password:digest
* adds password_digest attribute to the migration
* adds has_secure_password to the model
* adds password and password_confirmation password_fields to _form.html
* omits password entirely from 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
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/model.rb | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb b/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb index 3a3cf86d73..fd94a2d038 100644 --- a/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +++ b/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb @@ -2,8 +2,12 @@ class <%= migration_class_name %> < ActiveRecord::Migration def change create_table :<%= table_name %> do |t| <% attributes.each do |attribute| -%> +<% if attribute.password_digest? -%> + t.string :password_digest<%= attribute.inject_options %> +<% else -%> t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %> <% end -%> +<% end -%> <% if options[:timestamps] %> t.timestamps <% end -%> diff --git a/activerecord/lib/rails/generators/active_record/model/templates/model.rb b/activerecord/lib/rails/generators/active_record/model/templates/model.rb index 056f55470c..808598699b 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/model.rb +++ b/activerecord/lib/rails/generators/active_record/model/templates/model.rb @@ -1,7 +1,10 @@ <% module_namespacing do -%> class <%= class_name %> < <%= parent_class_name.classify %> -<% attributes.select {|attr| attr.reference? }.each do |attribute| -%> +<% attributes.select(&:reference?).each do |attribute| -%> belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %> <% end -%> +<% if attributes.any?(&:password_digest?) -%> + has_secure_password +<% end -%> end <% end -%> |