Ruby on Rails bcrypt-ruby错误

时间:2014-03-12 20:19:31

标签: ruby-on-rails ruby ruby-on-rails-4 bcrypt-ruby

我正在关注Michael Hartl的Rails 4教程,我正在研究用户身份验证部分。他说要将bcrypt-ruby添加到Gemfile,然后bundle install

这是我的Gemfile中的一行:

gem 'bcrypt-ruby', '3.1.2' // as explained at http://ruby.railstutorial.org/chapters/modeling-users#code-bcrypt_ruby

我运行bundle install然后rails console来测试系统。创建新用户会引发以下错误:

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.0.0), already activated bcrypt-ruby-3.1.2. Make sure all dependencies are added to Gemfile.

bundle install工作正常,没有任何错误 - 为什么这里失败了,错误说bcrypt-ruby没有安装?

编辑:这似乎与此问题重复:Unable to activate bcrypt-ruby (~> 3.0.0), already activated bcrypt-ruby-3.1.2?

1 个答案:

答案 0 :(得分:0)

您需要bcrypt-ruby版本3.0.0

更改Gemfile中的版本

gem 'bcrypt-ruby', '~> 3.0.0'