提交 8a9f4c6d 编写于 作者: A Aaron Patterson

Merge pull request #2825 from guilleiguaran/bcrypt-ruby-comments

Add comments about bcrypt-ruby gem to SecurePassword and add it to default Gemfile
...@@ -10,6 +10,10 @@ module ClassMethods ...@@ -10,6 +10,10 @@ module ClassMethods
# a "password_confirmation" attribute) are automatically added. # a "password_confirmation" attribute) are automatically added.
# You can add more validations by hand if need be. # You can add more validations by hand if need be.
# #
# You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use has_secure_password:
#
# gem 'bcrypt-ruby', '~> 3.0.0'
#
# Example using Active Record (which automatically includes ActiveModel::SecurePassword): # Example using Active Record (which automatically includes ActiveModel::SecurePassword):
# #
# # Schema: User(name:string, password_digest:string) # # Schema: User(name:string, password_digest:string)
...@@ -28,6 +32,8 @@ module ClassMethods ...@@ -28,6 +32,8 @@ module ClassMethods
# User.find_by_name("david").try(:authenticate, "notright") # => nil # User.find_by_name("david").try(:authenticate, "notright") # => nil
# User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user # User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user
def has_secure_password def has_secure_password
# Load bcrypt-ruby only when has_secured_password is used to avoid make ActiveModel
# (and by extension the entire framework) dependent on a binary library.
gem 'bcrypt-ruby', '~> 3.0.0' gem 'bcrypt-ruby', '~> 3.0.0'
require 'bcrypt' require 'bcrypt'
......
...@@ -10,6 +10,9 @@ source 'http://rubygems.org' ...@@ -10,6 +10,9 @@ source 'http://rubygems.org'
<%= assets_gemfile_entry %> <%= assets_gemfile_entry %>
<%= javascript_gemfile_entry %> <%= javascript_gemfile_entry %>
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server # Use unicorn as the web server
# gem 'unicorn' # gem 'unicorn'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册