未初始化的常量 ActionDispatch::Session::EncryptedCookieStore (NameError)
Posted
技术标签:
【中文标题】未初始化的常量 ActionDispatch::Session::EncryptedCookieStore (NameError)【英文标题】:uninitialized constant ActionDispatch::Session::EncryptedCookieStore (NameError) 【发布时间】:2013-03-28 11:46:19 【问题描述】:我和乘客一起在 4 号轨道上。一切都很好,直到我刚刚做了一个bundle
。现在我遇到以下错误:
Web application could not be started
uninitialized constant ActionDispatch::Session::EncryptedCookieStore (NameError)
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/application/configuration.rb:144:in `const_get'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/application/configuration.rb:144:in `session_store'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/application.rb:345:in `block in default_middleware_stack'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/application.rb:307:in `tap'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/application.rb:307:in `default_middleware_stack'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/engine.rb:494:in `app'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/application/finisher.rb:34:in `block in <module:Finisher>'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/initializable.rb:30:in `instance_exec'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/initializable.rb:30:in `run'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/initializable.rb:55:in `block in run_initializers'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/tsort.rb:180:in `each'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/initializable.rb:54:in `run_initializers'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/application.rb:214:in `initialize!'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/rails-2ac97df55230/railties/lib/rails/railtie/configurable.rb:30:in `method_missing'
/opt/ptolemy-web/config/environment.rb:5:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
/u/sf/ytl/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/passenger-7ef605967703/helper-scripts/rack-preloader.rb:82:in `eval'
/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/passenger-7ef605967703/helper-scripts/rack-preloader.rb:82:in `preload_app'
/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/passenger-7ef605967703/helper-scripts/rack-preloader.rb:127:in `<module:App>'
/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/passenger-7ef605967703/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/passenger-7ef605967703/helper-scripts/rack-preloader.rb:5:in `<main>'
我的宝石文件
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', github: 'rails/rails'
# database
gem 'pg'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', github: 'rails/sass-rails'
gem 'coffee-rails', github: 'rails/coffee-rails'
gem 'coffeebeans'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
gem 'uglifier', '>= 1.0.3'
end
# UI
gem 'jquery-rails'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'jquery-ui-rails'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'backbone-on-rails'
gem 'd3_rails'
gem 'rails-timeago'
gem 'dygraphs-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.0.1'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano', group: :development
# To use debugger
# gem 'debugger'
# UI middleware
gem 'passenger', github: 'FooBarWidget/passenger'
gem 'rack-webauth'
我的 google-foo 在这件事上相当薄弱。谁能帮忙?
【问题讨论】:
【参考方案1】:最近在 Rails 4 中删除了秘密 cookie 存储。请参阅 Changelog。
为了让您的应用再次运行,请将 config/initializers/session_store.rb 中的 config.session_store :encrypted_cookie_store
行替换为 config.session_store :cookie_store
。商店将自动加密。
如果不确定。创建一个新的 Rails 4 应用程序 (rails new app_name --pre
) 并查看初始化程序。
详情见according commit
【讨论】:
为我节省了一些时间。谢谢! 刚从 beta1 升级到 rc1,不知道去哪里找。救了我的命,莱夫。谢谢!以上是关于未初始化的常量 ActionDispatch::Session::EncryptedCookieStore (NameError)的主要内容,如果未能解决你的问题,请参考以下文章