为什么 model 里只要添加了 has_secure_password,执行 User.all 就无法取出里面的数据呢?
You don't have bcrypt-ruby installed in your application. Please add it to your
Gemfile and run bundle install
Gem::LoadError: can't activate bcrypt-ruby (~> 3.1.2), already activated bcrypt-
ruby-3.0.1-x86-mingw32. Make sure all dependencies are added to Gemfile.
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.8.2/lib/bundler/rubyg
ems_integration.rb:271:in block in replace_gem'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activemodel-4.0.2/lib/active_mo
del/secure_password.rb:47:in
has_secure_password'
from C:/Users/Administrator/sample_app/app/models/user.rb:8:in <class:U
ser>'
from C:/Users/Administrator/sample_app/app/models/user.rb:1:in
'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_
support/dependencies.rb:424:in load'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_
support/dependencies.rb:424:in
block in load_file'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_
support/dependencies.rb:616:in new_constants_in'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_
support/dependencies.rb:423:in
load_file'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_
support/dependencies.rb:324:in require_or_load'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_
support/dependencies.rb:463:in
load_missing_constant'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_
support/dependencies.rb:184:in const_missing'
from (irb):1
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/comman
ds/console.rb:90:in
start'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/comman
ds/console.rb:9:in start'
from D:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/comman
ds.rb:62:in
'
from bin/rails:4:in require'
from bin/rails:4:in
def change
add_column :users, :password_digest, :string
end
end
这是我最新迁移的数据库,执行了 bundle exec rake db:migrate。
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3' , '1.3.8'
gem 'rspec-rails' , '2.13.1'
end
group :test do
gem 'selenium-webdriver' , '2.35.1'
gem 'capybara' , '2.1.0'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc','0.3.20', require: false
end
group :production do
gem 'pg' , '0.15.1'
end
gem 'bootstrap-sass' , '2.3.2.0'
gem 'bcrypt-ruby' , '3.0.1'
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install