2

在我的 Rails 3.2.13 应用程序中,我有 layouts file <% if signed_in? %>,这行导致以下错误:

无法激活 bcrypt-ruby (~> 3.0.0),已激活 bcrypt-ruby-3.1.1-x86-mingw32。确保将所有依赖项添加到 Gemfile。

signed_in 方法放在我的 session_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)
4

2 回答 2

3

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

确保你的 Gemfile 中有这个:

gem 'bcrypt-ruby', '~> 3.0.0'
于 2013-07-26T23:29:15.973 回答
0

在你的 gemfile 中取消注释 bcrypt-ruby gem

gem 'bcrypt-ruby'

bundle update bcrypt-ruby
于 2013-07-22T04:37:32.373 回答