Kic*_*ang 12 ruby-on-rails ruby-on-rails-3
当我将has_secure_password添加到模型(继承自ActiveRecord :: Base)时,会出现错误,指出"bcrypt-ruby不是bundle的一部分".
这里的日志是:
Started GET "/users" for 127.0.0.1 at 2012-02-19 16:37:12 +0900
Gem::LoadError (bcrypt-ruby is not part of the bundle. Add it to Gemfile.):
app/models/user.rb:3:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/controllers/users_controller.rb:1:in `<top (required)>'
Run Code Online (Sandbox Code Playgroud)
我安装了bcrypt-ruby
$ gem install bcrypt-ruby
Building native extensions. This could take a while...
1 gem installed
Installing YARD (yri) index for bcrypt-ruby-3.0.1...
Installing RDoc documentation for bcrypt-ruby-3.0.1...
Run Code Online (Sandbox Code Playgroud)
但无济于事.
我试过了
$ bundle exec rails server
Run Code Online (Sandbox Code Playgroud)
但没有帮助.
如果我注释掉"has_secure_password"这一行,则不会出现此错误.
我怎么解决这个问题?
use*_*833 23
我已经gem 'bcrypt-ruby', '~> 3.0.0'
在Gemfile中了,并且已经运行了命令bundle
,但我仍然收到了该消息.问题是我忘了重启服务器:
touch tmp/restart.txt
Run Code Online (Sandbox Code Playgroud)
Fre*_*ung 13
正如消息所示,您需要将bcrypt-ruby添加到您的Gemfile中(在项目的根目录下).
添加
gem "bcrypt-ruby"
Run Code Online (Sandbox Code Playgroud)
然后运行bundle install
应该做的伎俩(如果你还没有安装它,这将获取gem).
您可以指定特定版本,例如
gem "bcrypt-ruby", "~> 3.0.1"
Run Code Online (Sandbox Code Playgroud)
将为您提供最新版本> =至3.0.1但小于3.1.你可能会这样做,如果3.0.1有一个你依赖的错误修复,你很高兴得到更多的错误修复但你不想要重大改变.在bundler网站上加载了更多信息.
小智 6
在你的Gemfile中添加一行
gem 'bcrypt-ruby'
Run Code Online (Sandbox Code Playgroud)
然后从命令行
bundle install
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10006 次 |
最近记录: |