Ruby on Rails中的Bcrypt gem

时间:2017-05-12 15:53:01

标签: ruby-on-rails bcrypt

我刚刚创建了一个新的 Rails 5 应用程序。我的应用程序中还没有生成任何MVC。

我在gem文件中添加了一些宝石,包括gem 'bcrypt', '3.1.11'

当我尝试使用rails生成器创建控制器时,出现错误。

这是带有错误的命令:

命令> rails generate controller StaticPages home help

C:/Ruby23/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `require': cannot load such file -- bcrypt_ext (LoadError)
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
        from C:/Users/Doesha/Desktop/rails17/rails_sample_app/config/application.rb:7:in `<top (required)>'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:156:in `require'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:156:in `require_application_and_environment!'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:143:in `generate_or_destroy'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:60:in `generate'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

我所做的只是将gem添加到我的gemfile中,所以我不确定为什么rails生成器不起作用。

当我添加gem bcrypt时,我注意到我的生成器停止工作。

有人可以告诉我在安装gem 'bcrypt', '3.1.11'后我无法使用我的发电机的原因吗?

1 个答案:

答案 0 :(得分:0)

从gem文件中删除 gem&#39; bcrypt&#39; 3.1.11&#39; 使用 $ gem install bcrypt