Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
946 views
in Technique[技术] by (71.8m points)

ruby on rails - Devise Issue : TypeError - [17] is not a symbol

I recently ran a bundle update and now I am getting a weird

Type - [17] is not a symbol error.

This is the full error message:

Started GET "/" for 127.0.0.1 at 2013-05-14 03:46:35 -0500

TypeError - [17] is not a symbol:
  (gem) activesupport-3.2.13/lib/active_support/inflector/methods.rb:230:in `block in constantize'
  (gem) activesupport-3.2.13/lib/active_support/inflector/methods.rb:229:in `constantize'
  (gem) devise-2.2.3/lib/devise/rails/warden_compat.rb:27:in `deserialize'
  (gem) warden-1.2.1/lib/warden/session_serializer.rb:35:in `fetch'
  (gem) warden-1.2.1/lib/warden/proxy.rb:212:in `user'
  (gem) warden-1.2.1/lib/warden/proxy.rb:318:in `_perform_authentication'
  (gem) warden-1.2.1/lib/warden/proxy.rb:104:in `authenticate'
  (gem) warden-1.2.1/lib/warden/proxy.rb:114:in `authenticate?'
  (gem) devise-2.2.3/lib/devise/rails/routes.rb:286:in `block in authenticated'
  (gem) actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:31:in `block in matches?'
  (gem) actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:28:in `matches?'
  (gem) actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:42:in `call'
  (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
  (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
  (gem) rack-pjax-0.7.0/lib/rack/pjax.rb:12:in `call'
  (gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/error_collector.rb:12:in `call'
  (gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/agent_hooks.rb:18:in `call'
  (gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/browser_monitoring.rb:16:in `call'
  (gem) bullet-4.6.0/lib/bullet/rack.rb:10:in `call'
  (gem) meta_request-0.2.3/lib/meta_request/middlewares/app_request_handler.rb:11:in `call'
  (gem) rack-contrib-1.1.0/lib/rack/contrib/response_headers.rb:17:in `call'
  (gem) meta_request-0.2.3/lib/meta_request/middlewares/headers.rb:16:in `call'
  (gem) meta_request-0.2.3/lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
  (gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
  (gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  (gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
  (gem) rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call'
  (gem) remotipart-1.0.5/lib/remotipart/middleware.rb:30:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call'
  (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
  (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call'
  (gem) activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call'
  (gem) activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__1566733404690363964__call__3169664716453937753__callbacks'
  (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
  (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:65:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:84:in `protected_app_call'
  (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:79:in `better_errors_call'
  (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:56:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  (gem) railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app'
  (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call'
  (gem) activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged'
  (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `call'
  (gem) quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call'
  (gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
  (gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call'
  (gem) activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  (gem) rack-1.4.5/lib/rack/lock.rb:15:in `call'
  (gem) actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call'
  (gem) railties-3.2.13/lib/rails/engine.rb:479:in `call'
  (gem) railties-3.2.13/lib/rails/application.rb:223:in `call'
  (gem) rack-1.4.5/lib/rack/content_length.rb:14:in `call'
  (gem) railties-3.2.13/lib/rails/rack/log_tailer.rb:17:in `call'
  (gem) thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
  (gem) thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
  (gem) thin-1.5.1/lib/thin/connection.rb:54:in `process'
  (gem) thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
  (gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
  (gem) thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
  (gem) thin-1.5.1/lib/thin/server.rb:159:in `start'
  (gem) rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
  (gem) rack-1.4.5/lib/rack/server.rb:268:in `start'
  (gem) railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
  (gem) railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
  (gem) railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
  script/rails:6:in `<main>'

I am at a complete loss as to what could be causing this all of a sudden.

Don't know if this will help, but this is my Gemfile.lock:

GIT
  remote: git://github.com/ctran/annotate_models.git
  revision: 8bd159c7a484093fde84beaa9e6398f25ddacf09
  specs:
    annotate (2.6.0.beta1)
      activerecord (>= 2.3.0)
      rake (>= 0.8.7)

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)
    active_utils (1.0.5)
      activesupport (>= 2.3.11)
      i18n
    activemerchant (1.32.1)
      active_utils (>= 1.0.2)
      activesupport (>= 2.3.14)
      builder (>= 2.0.0)
      i18n
      json (>= 1.5.1)
      money
      nokogiri
    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)
    addressable (2.3.4)
    arel (3.0.2)
    autoparse (0.3.3)
      addressable (>= 2.3.1)
      extlib (>= 0.9.15)
      multi_json (>= 1.0.0)
    bcrypt-ruby (3.0.1)
    better_errors (0.8.0)
      coderay (>= 1.0.0)
      erubis (>= 2.6.6)
    binding_of_caller (0.7.1)
      debug_inspector (>= 0.0.1)
    bootstrap-sass (2.3.1.0)
      sass (~> 3.2)
    bootstrap-wysihtml5-rails (0.3.1.19)
      railties (>= 3.0)
    builder (3.0.4)
    bullet (4.6.0)
      uniform_notifier
    cancan (1.6.9)
    carrierwave (0.8.0)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
    coderay (1.0.9)
    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.2)
    countries (0.9.2)
      currencies (>= 0.4.0)
    currencies (0.4.0)
    daemons (1.1.9)
    database_cleaner (1.0.0.RC1)
    debug_inspector (0.0.2)
    devise (2.2.3)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (~> 3.1)
      warden (~> 1.2.1)
    diff-lcs (1.2.4)
    email_spec (1.4.0)
      launchy (~> 2.1)
      mail (~> 2.2)
    erubis (2.7.0)
    eventmachine (1.0.3)
    excon (0.21.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    extlib (0.9.16)
    faraday (0.8.7)
      multipart-post (~> 1.1)
    fog (1.11.0)
      builder
      excon (~> 0.20)
      formatador (~> 0.2.0)
      google-api-client (~> 0.6.2)
      json (~> 1.7)
      mime-types
      net-scp (~> 1.1)
      net-ssh (>= 2.1.3)
      nokogiri (~> 1.5.0)
      ruby-hmac
    font-awesome-sass-rails (3.0.2.2)
      railties (>= 3.1.1)
      sass-rails (>= 3.1.1)
    formatador (0.2.4)
    friendly_id (4.0.9)
    google-api-client (0.6.3)
      addressable (>= 2.3.2)
      autoparse (>= 0.3.3)
      extlib (>= 0.9.15)
      faraday (~> 0.8.4)
      jwt (>= 0.1.5)
      launchy (>= 2.1.1)
      multi_json (>= 1.0.0)
      signet (>= 0.4.4)
      uuidtools (>= 2.1.0)
    haml (4.0.2)
      tilt
    hike (1.2.2)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (2.2.1)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (3.0.1)
      jquery-rails
      railties (>= 3.1.0)
    json (1.7.7)
    jwt (0.1.8)
      multi_json (>= 1.5)
    kaminari (0.14.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    launchy (2.3.0)
      addressable (~> 2.3)
    letter_opener (1.0.0)
      launchy (>= 2.0.4)
    libv8 (3.11.8.17)
    mail (2.5.3)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    meta_request (0.2.3)
      rack-contrib
      railties
    mime-types (1.23)
    mini_magick (3.5.0)
      subexec (~> 0.2.1)
    money (5.1.1)
      i18n (~> 0.6.0)
    multi_json (1.7.2)
    multipart-post (1.2.0)
    nested_form (0.3.2)
    net-scp (1.1.0)
      net-ssh (>= 2.6.5)
    net-ssh (2.6.7)
    newrelic_rpm (3.6.1.88)
    nokogiri (1.5.9)
    orm_adapter (0.4.0)
    pg (0.15.1)
    piggybak (0.6.30)
      activemerchant
      countries
      devise
      rack-ssl-enforcer
      rails (~> 3.2.8)
      rails_admin (~> 0.4.5)
    piggybak_bundle_discounts (0.0.5)
      rails (~> 3.2.8)
    piggybak_stripe (0.0.2)
      stripe (= 1.7.4)
    piggybak_variants (0.0.17)
      rails (~> 3.2.3)
    polyglot (0.3.3)
    quiet_assets (1.0.2)
      railties (>= 3.1, < 5.0)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-contrib (1.1.0)
      rack (>= 0.9.1)
    rack-pjax (0.7.0)
      nokogiri (~> 1.5)
      rack (~> 1.3)
    rack-ssl (1.3.3)
      rack
    rack-ssl-enforcer (0.2.5)
    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)
    rails_admin (0.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are a few things to note here:

  1. It's safer to specify maximum versions to update to in your Gemfile
  2. Your session is not deserializing correctly - this is the cause of the exception you're seeing
  3. If you're having trouble with a single gem and need to update, use bundle update <gem name>

Specify maximum Gem versions

You should get into the practice of using the pessimistic version constraint (the ~> operator) in your Gemfile. This essentially allows you to say that gems can only be updated to higher patch levels.

Ruby developers tend to use the standard of version numbers with three numbers: x.x.x, e.g. 2.0.1. The first number is the major version, the second number the minor version and the third number is the patch.

Major version updates are likely to break old functionality. If you upgrade from 1.x.x to 2.x.x, it could be a painful process. Minor version updates should add features and, in rare cases, change existing functionality, but it should be backwards compatible. Patch level updates should be purely bug fixes.

The pessimistic version constraint can be used to say "only allow patch level updates". For example:

gem 'devise', '~> 2.2.3'  # Only the '.3' can increase, e.g. 2.2.4, 2.2.5

If you do this for all of your gems then you can be reasonably sure that bundle update will update gems to compatible versions. In your Gemfile you have

gem 'devise', '>= 2.2.3'

This would potentially allow the installation of devise 3.0.0, which you can almost guarantee would be problematic.

It's good practice to find a gem configuration that works, then use the pessimistic version constraint to lock your Gemfile down to only patch level updates.

Session deserialization

It looks like devise has been updated, which has caused a session deserialization problem. You could check out an old version of your Gemfile.lock, then downgrade to the devise version that was working. Or you could just clear your cache if you don't have anything critical in the session and use the new version.

Update a single gem

Running bundle update will attempt to update all gems in your Gemfile. If you only need to update a single gem, use bundle update <gem name>. All the others will remain at the same version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...