Error stating that “bcrypt-ruby is not part of the bundle”, how can I add bcrypt-ruby to Gemfile?

后端 未结 6 736
伪装坚强ぢ
伪装坚强ぢ 2021-01-11 12:10

When I add has_secure_password to the model (inherited from ActiveRecord::Base), error stating that \"bcrypt-ruby is not part of the bundle\" occurs.

Here the log is

6条回答
  •  醉话见心
    2021-01-11 12:39

    As the message says you need to add bcrypt-ruby to your Gemfile (at the root of the project).

    Adding

    gem "bcrypt-ruby"
    

    and then running bundle install should do the trick (this would fetch the gem if you hadn't already installed it).

    You can specify specific versions to, eg

    gem "bcrypt-ruby", "~> 3.0.1"
    

    will get you the latest version that is >= to 3.0.1 but less than 3.1. You might do this if 3.0.1 has a bug fix you depend on and you're happy to get more bug fixes but you don't want major changes. There's loads more info on the bundler website.

提交回复
热议问题