2013-04-30 68 views
4

我一直被困在這個錯誤大約3天了,我無法弄清楚如何糾正它。任何幫助,將不勝感激。configuration.rb:140:在`const_get':未初始化的常量ActionDispatch :: Session :: EncryptedCookieStore(NameError)

我在Windows機器上的方式,我使用Ruby v.1.9.3p392 & Rails的v 3.2.13

我發出的錯誤是以前的命令:

'軌生成腳手架用戶名:字符串email:字符串'

這是下面的錯誤:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/a 
pplication/configuration.rb:140:in `const_get': uninitialized constant ActionDis 
patch::Session::EncryptedCookieStore (NameError) 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application/configuration.rb:140:in `session_store' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application.rb:273:in `block in default_middleware_stack' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application.rb:237:in `tap' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application.rb:237:in `default_middleware_stack' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/engine.rb:469:in `app' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application/finisher.rb:31:in `block in <module:Finisher>' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/initializable.rb:30:in `instance_exec' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/initializable.rb:30:in `run' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/initializable.rb:55:in `block in run_initializers' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/initializable.rb:54:in `each' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/initializable.rb:54:in `run_initializers' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application.rb:136:in `initialize!' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/railtie/configurable.rb:30:in `method_missing' 
     from C:/ruby/rails_projects/demo_app/config/environment.rb:5:in `<top (r 
equired)>' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application.rb:103:in `require' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/application.rb:103:in `require_environment!' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/commands.rb:25:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 

這是我configuration.rb文件(它不顯示有關 「加密」 的任何東西)

require 'active_support/core_ext/string/encoding' 
require 'active_support/core_ext/kernel/reporting' 
require 'active_support/file_update_checker' 
require 'rails/engine/configuration' 

module Rails 
    class Application 
    class Configuration < ::Rails::Engine::Configuration 
     attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets, 
        :cache_classes, :cache_store, :consider_all_requests_local, 
        :dependency_loading, :exceptions_app, :file_watcher, :filter_parameters, 
        :force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks, 
        :railties_order, :relative_url_root, :reload_plugins, :secret_token, 
        :serve_static_assets, :ssl_options, :static_cache_control, :session_options, 
        :time_zone, :reload_classes_only_on_change, :whiny_nils 

     attr_writer :log_level 
     attr_reader :encoding 

     def initialize(*) 
     super 
     self.encoding = "utf-8" 
     @allow_concurrency    = false 
     @consider_all_requests_local = false 
     @filter_parameters    = [] 
     @helpers_paths     = [] 
     @dependency_loading   = true 
     @serve_static_assets   = true 
     @static_cache_control   = nil 
     @force_ssl      = false 
     @ssl_options     = {} 
     @session_store     = :cookie_store 
     @session_options    = {} 
     @time_zone      = "UTC" 
     @log_level      = nil 
     @middleware     = app_middleware 
     @generators     = app_generators 
     @cache_store     = [ :file_store, "#{root}/tmp/cache/" ] 
     @railties_order    = [:all] 
     @relative_url_root    = ENV["RAILS_RELATIVE_URL_ROOT"] 
     @reload_classes_only_on_change = true 
     @file_watcher     = ActiveSupport::FileUpdateChecker 
     @exceptions_app    = nil 

     @assets = ActiveSupport::OrderedOptions.new 
     @assets.enabled     = false 
     @assets.paths     = [] 
     @assets.precompile    = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) }, 
              /(?:\/|\\|\A)application\.(css|js)$/ ] 
     @assets.prefix     = "/assets" 
     @assets.version     = '' 
     @assets.debug     = false 
     @assets.compile     = true 
     @assets.digest     = false 
     @assets.manifest     = nil 
     @assets.cache_store    = [ :file_store, "#{root}/tmp/cache/assets/" ] 
     @assets.js_compressor   = nil 
     @assets.css_compressor   = nil 
     @assets.initialize_on_precompile = true 
     @assets.logger     = nil 
     end 

     def compiled_asset_path 
     "/" 
     end 

     def encoding=(value) 
     @encoding = value 
     if "ruby".encoding_aware? 
      silence_warnings do 
      Encoding.default_external = value 
      Encoding.default_internal = value 
      end 
     else 
      $KCODE = value 
      if $KCODE == "NONE" 
      raise "The value you specified for config.encoding is " \ 
        "invalid. The possible values are UTF8, SJIS, or EUC" 
      end 
     end 
     end 

     def paths 
     @paths ||= begin 
      paths = super 
      paths.add "config/database", :with => "config/database.yml" 
      paths.add "config/environment", :with => "config/environment.rb" 
      paths.add "lib/templates" 
      paths.add "log",    :with => "log/#{Rails.env}.log" 
      paths.add "public" 
      paths.add "public/javascripts" 
      paths.add "public/stylesheets" 
      paths.add "tmp" 
      paths 
     end 
     end 

     # Enable threaded mode. Allows concurrent requests to controller actions and 
     # multiple database connections. Also disables automatic dependency loading 
     # after boot, and disables reloading code on every request, as these are 
     # fundamentally incompatible with thread safety. 
     def threadsafe! 
     self.preload_frameworks = true 
     self.cache_classes = true 
     self.dependency_loading = false 
     self.allow_concurrency = true 
     self 
     end 

     # Loads and returns the contents of the #database_configuration_file. The 
     # contents of the file are processed via ERB before being sent through 
     # YAML::load. 
     def database_configuration 
     require 'erb' 
     YAML::load(ERB.new(IO.read(paths["config/database"].first)).result) 
     end 

     def log_level 
     @log_level ||= Rails.env.production? ? :info : :debug 
     end 

     def colorize_logging 
     @colorize_logging 
     end 

     def colorize_logging=(val) 
     @colorize_logging = val 
     ActiveSupport::LogSubscriber.colorize_logging = val 
     self.generators.colorize_logging = val 
     end 

     def session_store(*args) 
     if args.empty? 
      case @session_store 
      when :disabled 
      nil 
      when :active_record_store 
      ActiveRecord::SessionStore 
      when Symbol 
      ActionDispatch::Session.const_get(@session_store.to_s.camelize) 
      else 
      @session_store 
      end 
     else 
      @session_store = args.shift 
      @session_options = args.shift || {} 
     end 
     end 
    end 
    end 
end 

這裏是我的Gemfile:

source 'https://rubygems.org' 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 

gem 'rails', '3.2.13' 



group :development do 
    gem 'sqlite3', '1.3.7' 
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' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer', platforms: :ruby 

    gem 'uglifier', '>= 1.2.3' 
end 

gem 'jquery-rails', '2.0.2' 

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

# 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' 

好了,從移除單詞 'Encrypted_' 後session_store.rb文件。它帶走了EncryptedCookieStore(NameError)和下面的下面的錯誤現在已經上來了,但我不確定他們是否是相關的:

C:\ruby\rails_projects\demo_app>rails generate scaffold User name:string email:s 
tring 
     invoke active_record 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/act 
ive_record/dynamic_matchers.rb:55:in `method_missing': undefined method `migrati 
on_error=' for ActiveRecord::Base:Class (NoMethodError) 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3 
.2.13/lib/active_record/railtie.rb:66:in `block (3 levels) in <class:Railtie>' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3 
.2.13/lib/active_record/railtie.rb:65:in `each' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3 
.2.13/lib/active_record/railtie.rb:65:in `block (2 levels) in <class:Railtie>' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3 
.2.13/lib/active_record/base.rb:720:in `<top (required)>' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/generators/named_base.rb:166:in `pluralize_table_names?' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/generators/named_base.rb:114:in `table_name' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3 
.2.13/lib/rails/generators/active_record/model/model_generator.rb:17:in `create_ 
migration_file' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/command.rb:27:in `run' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:120:in `invoke_command' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `block in invoke_all' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `each' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `map' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `invoke_all' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/group.rb:233:in `dispatch' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:109:in `invoke' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/group.rb:278:in `block in _invoke_for_class_method' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/shell.rb:74:in `with_padding' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/group.rb:267:in `_invoke_for_class_method' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/group.rb:150:in `_invoke_from_option_orm' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/command.rb:27:in `run' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:120:in `invoke_command' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `block in invoke_all' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `each' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `map' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/invocation.rb:127:in `invoke_all' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/group.rb:233:in `dispatch' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/li 
b/thor/base.rb:439:in `start' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/generators.rb:171:in `invoke' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/commands/generate.rb:12:in `<top (required)>' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/dependencies.rb:251:in `require' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/dependencies.rb:251:in `block in require' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport- 
3.2.13/lib/active_support/dependencies.rb:251:in `require' 
     from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 
3/lib/rails/commands.rb:29:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 

回答

6

進入config/initializers/session_store.rb和變化:

App::Application.config.session_store :encrypted_cookie_store, key: '_app_session' 

到:

App::Application.config.session_store :cookie_store, key: '_app_session' 

最近刪除了編碼的cookie存儲。希望能幫助到你。

+0

我遇到過從Rails 4.0.0.beta1升級到4.0.0.rc1的這個問題。你的回答解決了問題 - 謝謝! – Jurgen 2013-05-03 00:41:01

+0

謝謝你 - 這工作,但似乎在再次運行命令後出現一大堆其他錯誤。我不確定他們是否有關係。 – LilithX 2013-05-03 16:33:03

+0

@LilithX你可以發佈你正在獲得的其他問題,只需將它們追加到你原來的問題或開始一個新的問題。 – stephenmurdoch 2013-05-03 21:49:59

相關問題