LoginSignup
0

More than 5 years have passed since last update.

has_secure_passwordを使うとcannot load such file -- bcryptが出る

Posted at

https://railstutorial.jp/chapters/modeling_users?version=5.1#sec-a_hashed_password

セキュアなパスワードの実装は、has_secure_passwordというRailsのメソッドを呼び出すだけでほとんど終わってしまいます。このメソッドは、Userモデルで次のように呼び出せます。

user.rb
class User < ApplicationRecord
  has_secure_password
end

上のようにモデルにこのメソッドを追加すると、次のような機能が使えるようになります。

加えると以下のエラーが出るようになった。
cannot load such file -- bcrypt

gemを確認する

gem list

Using bcrypt 3.1.12 (x86-mingw32)

なんだこの、(x86-mingw32)というのは。違うでしょ、railsで使うんでしょ。

gem uninstall bcrypt
gem install bcrypt --platform=ruby

上記を実行したうえで再起動したら直った~。

いろいろありますなあ。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0