ruby-on-rails - Rails 3.2.13 - Gem::LoadError,无法激活 gem

标签 ruby-on-rails ruby web-applications bcrypt

在我的 Rails 3.2.13 应用程序中,我有布局文件 <% if signed_in? %> ,并且此行导致以下错误:

can't activate bcrypt-ruby (~> 3.0.0), already activated bcrypt-ruby-3.1.1-x86-mingw32. Make sure all dependencies are added to Gemfile.

signed_in 方法放置在我的sessions_helper.rb 中:

def signed_in?
    !current_user.nil?
end

def current_user
    @current_user ||= User.find_by_remember_token(cookies[:remember_token])
end

我尝试删除 Gemfile.lock 然后运行 ​​bundle install ,但没有任何影响。我还尝试更改 Gemfile.lock 文件的内容,但也不起作用。

请大家指点一下我应该做什么,谢谢!


我的Gemfile 看起来像这样:

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'bootstrap-sass'
gem 'bcrypt-ruby'
gem 'faker'
gem 'will_paginate'
gem 'bootstrap-will_paginate'
gem 'jquery-rails'
gem 'sunspot_rails', '~> 1.3.0'
gem 'sunspot_solr'
gem 'html2markdown'
gem 'acts-as-taggable-on'
gem 'best_in_place', github: 'aaronchi/best_in_place'
gem 'gon'
gem 'cocoon'

#gem 'active_reload'


group :development, :test do
  gem 'sqlite3'
  gem 'rspec-rails'
end

group :development do
  gem 'annotate', '2.5.0'
end 
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'factory_girl_rails', '4.1.0'
  gem 'cucumber-rails', '1.2.1', :require => false
  gem 'database_cleaner', '0.7.0'
  # gem 'launchy', '2.1.0'
  # gem 'rb-fsevent', '0.9.1', :require => false
  # gem 'growl', '1.0.3'
end

group :production do
  gem 'pg', '0.12.2'
end

我的Gemfile.lock看起来像这样:

GIT
  remote: git://github.com/aaronchi/best_in_place.git
  revision: 1152e2256afd485e66602833fd99d09d60994841
  specs:
    best_in_place (2.1.0)
      jquery-rails
      rails (>= 3.1)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.13)
      actionpack (= 3.2.13)
      mail (~> 2.5.3)
    actionpack (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
    activerecord (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
    activesupport (3.2.13)
      i18n (= 0.6.1)
      multi_json (~> 1.0)
    acts-as-taggable-on (2.4.1)
      rails (>= 3, < 5)
    annotate (2.5.0)
      rake
    arel (3.0.2)
    bcrypt-ruby (3.1.1)
    bcrypt-ruby (3.1.1-x86-mingw32)
    bootstrap-sass (2.3.2.1)
      sass (~> 3.2)
    bootstrap-will_paginate (0.0.9)
      will_paginate
    builder (3.0.4)
    capybara (1.1.2)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    childprocess (0.3.9)
      ffi (~> 1.0, >= 1.0.11)
    cocoon (1.2.0)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    cucumber (1.3.5)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12.0)
      multi_json (~> 1.7.5)
      multi_test (>= 0.0.2)
    cucumber-rails (1.2.1)
      capybara (>= 1.1.2)
      cucumber (>= 1.1.3)
      nokogiri (>= 1.5.0)
    database_cleaner (0.7.0)
    diff-lcs (1.2.4)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (4.1.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.1.0)
      factory_girl (~> 4.1.0)
      railties (>= 3.0.0)
    faker (1.1.2)
      i18n (~> 0.5)
    ffi (1.9.0-x86-mingw32)
    gherkin (2.12.0-x86-mingw32)
      multi_json (~> 1.3)
    gon (4.1.1)
      actionpack (>= 2.3.0)
      json
    hike (1.2.3)
    html2markdown (0.0.3)
      nokogiri
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (3.0.4)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.0)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.23)
    mini_portile (0.5.1)
    multi_json (1.7.7)
    multi_test (0.0.2)
    nokogiri (1.6.0-x86-mingw32)
      mini_portile (~> 0.5.0)
    pg (0.12.2-x86-mingw32)
    polyglot (0.3.3)
    pr_geohash (1.0.0)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.13)
      actionmailer (= 3.2.13)
      actionpack (= 3.2.13)
      activerecord (= 3.2.13)
      activeresource (= 3.2.13)
      activesupport (= 3.2.13)
      bundler (~> 1.0)
      railties (= 3.2.13)
    railties (3.2.13)
      actionpack (= 3.2.13)
      activesupport (= 3.2.13)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.1.0)
    rdoc (3.12.2)
      json (~> 1.4)
    rsolr (1.0.9)
      builder (>= 2.1.2)
    rspec-core (2.14.3)
    rspec-expectations (2.14.0)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.1)
    rspec-rails (2.14.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    rubyzip (0.9.9)
    sass (3.2.9)
    sass-rails (3.2.5)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.33.0)
      childprocess (>= 0.2.5)
      multi_json (~> 1.0)
      rubyzip
      websocket (~> 1.0.4)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.7-x86-mingw32)
    sunspot (1.3.3)
      pr_geohash (~> 1.0)
      rsolr (~> 1.0.7)
    sunspot_rails (1.3.3)
      nokogiri
      sunspot (= 1.3.3)
    sunspot_solr (2.0.0)
    thor (0.18.1)
    tilt (1.4.1)
    treetop (1.4.14)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.37)
    uglifier (1.2.3)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)
    websocket (1.0.7)
    will_paginate (3.0.4)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  acts-as-taggable-on
  annotate (= 2.5.0)
  bcrypt-ruby
  best_in_place!
  bootstrap-sass
  bootstrap-will_paginate
  capybara (= 1.1.2)
  cocoon
  coffee-rails (= 3.2.2)
  cucumber-rails (= 1.2.1)
  database_cleaner (= 0.7.0)
  factory_girl_rails (= 4.1.0)
  faker
  gon
  html2markdown
  jquery-rails
  pg (= 0.12.2)
  rails (= 3.2.13)
  rspec-rails
  sass-rails (= 3.2.5)
  sqlite3
  sunspot_rails (~> 1.3.0)
  sunspot_solr
  uglifier (= 1.2.3)
  will_paginate

正在运行gem list bcrypt-ruby给出:

*** LOCAL GEMS ***

bcrypt-ruby (3.1.1 x86-mingw32, 3.0.1 x86-mingw32, 3.0.0 x86-mingw32)

最佳答案

您是否使用 Rails has_secure_password 功能?如果是这样,您必须使用 bcrypt-ruby 3.0.x。

确保您的 Gemfile 中有此内容:

gem 'bcrypt-ruby', '~> 3.0.0'

关于ruby-on-rails - Rails 3.2.13 - Gem::LoadError,无法激活 gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17780018/

相关文章:

ruby-on-rails - 将分块传输与内容处置一起使用

php - 识别可疑登录的可靠方法有哪些?

java - 如何解决 SSLHandshakeException ?为什么我得到它?

mysql - Thinking Sphinx 和 rails : Lost connection to MySQL server at 'reading initial communication packet' error

ruby-on-rails - 在共享示例调用中的 let 中使用循环变量

ruby-on-rails - Ruby 中 For 和 Map 的区别

ruby - 简单神经网络无法学习 XOR

ruby - 有没有一种或更有效的方法来完成这项工作?

javascript - 如何从我的 HTML CSS 和 JS 文件创建可重用的 javascript 网络应用程序

ruby-on-rails - Rails片段缓存呈现液体模板