Rails has_secure_password无法加载这样的文件 - bcrypt [英] Rails has_secure_password cannot load such file -- bcrypt
问题描述
我试图在Ruby on Rails中创建简单的身份验证。
我目前陷入困境,因为在数据库中创建表并添加模型
has_secure_password
我得到错误 LoadError:无法加载这样的文件 - bcrypt
。 当我在
rails console
中使用基本命令尝试时发生错误: User.all $ c $
我看过很多解决方案,但没有任何帮助。
目前我已经安装了bcrypt,它来自 https ://github.com/codahale/bcrypt-ruby.git
但仍然无法使用。
预先感谢您的帮助。
解决方案 在> windows 10
第1步
gem uninstall bcrypt
gem uninstall bcrypt-ruby
第2步
gem install bcrypt --platform = ruby
第3步
添加到您的Gemfile中
gem'bcrypt',平台::ruby
设计
如果您使用设计,那么不需要广告d在您的gem文件上加密宝石,请按照以下步骤操作:
gem卸载bcrypt
gem install bcrypt --platform = ruby
最后,重新启动服务器
帮助
I'm trying to create simple authentication in Ruby on Rails.
I'm currently stuck, because after creating table in database and adding in model has_secure_password
I'm getting error LoadError: cannot load such file -- bcrypt
.
The error occur when I'm trying in rails console
using basic command: User.all
.
I have looked at many solutions but nothing helped me.
Currently I have installed bcrypt from https://github.com/codahale/bcrypt-ruby.git
but still not working.
Thank you in advance for your help.
解决方案 On windows 10
I I solved this using this steps
Step 1.
gem uninstall bcrypt
gem uninstall bcrypt-ruby
Step 2
gem install bcrypt --platform=ruby
Step 3
Add to your Gemfile
gem 'bcrypt', platforms: :ruby
devise
If you use devise then not need add bcrypt gem on your gem file follow below steps
gem uninstall bcrypt
gem install bcrypt --platform=ruby
Finally, restart your server
Hope to help
这篇关于Rails has_secure_password无法加载这样的文件 - bcrypt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文