问题
I'm beginner in Ruby on Rails and trying to learn from http://ruby.railstutorial.org/ I'm creating sample_app and got stuck at chapter 6.
My Ruby version: ruby 2.0.0p195 (2013-05-14) [i386-mingw32]
My Rails version: Rails 4.0.0
I have following line in my GemFile:
gem 'bcrypt-ruby', '~> 3.0.0'
If I type gem list bcrypt-ruby
, it shows bcrypt-ruby (3.0.1)
. But if I try to create user, I get error saying
You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install
I searched a lot on rails website, bcrypt website & even stackoverflow. But, nothing worked. Please help.
回答1:
I've faced this issue recently (as have many others). As per ladyruby723 posted here, use gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
in your gemfile file.
回答2:
I solved this the same problem by the following line:
gem 'bcrypt-ruby', '~> 3.1.2'
回答3:
Finally... Got it working.. Didn't understand exact issue but I made two important changes. I'm not sure which change made it working.. 1. I uninstalled my old ruby & rails that was installed from railsinstaller. Installed just ruby for my OS (64 bit which i was not able to choose while installing from railsinstaller). Then I installed rails, sqlite3 separately. 2. Another important change I did is in GemFile.lock . I think this did the trick. I kept both of following lines
bcrypt-ruby (3.0.0)
bcrypt-ruby (3.0.0-x86-mingw32)
回答4:
I believe this exact issue is solved in another question. There are actually two error messages produced, this being the higher level one, by searching for the lower level I found the below answer.
can't activate bcrypt-ruby (~> 3.0.0), already activated bcrypt-ruby-3.1.1. Make sure all dependencies are added to Gemfile
回答5:
add below in gem file
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
and run bundle install and restart server
来源:https://stackoverflow.com/questions/18916040/bcrypt-ruby-you-dont-have-bcrypt-ruby-installed-in-your-application