从Rails 2.3.5升级到3.2时:未定义的方法`protected_instance_variables =`for ActionController :: Base:Class(NoMethodError)

时间:2013-03-17 01:40:53

标签: ruby-on-rails ruby-on-rails-3.2

我一直在关注一些指南,将一个相当宝石重的系统从Rails 2.3.5升级到Rails 3.2.17。虽然升级到Rails后我遇到的大多数问题都是关于升级ActiveRecord调用,或者安装或升级Gem,但是当我运行“ bundle exec rails s 时,我完全被以下堆栈跟踪困扰了strong>“启动服务器:

$ bundle exec rails s
=> Booting Thin
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/actionpack-3.2.12/lib/action_controller/metal/compatibility.rb:22:in `block in <module:Compatibility>': undefined method `protected_instance_variables=' for ActionController::Base:Class (NoMethodError)
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/concern.rb:119:in `class_eval'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/concern.rb:119:in `append_features'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/actionpack-3.2.12/lib/action_controller/base.rb:231:in `include'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/actionpack-3.2.12/lib/action_controller/base.rb:231:in `<class:Base>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/actionpack-3.2.12/lib/action_controller/base.rb:171:in `<module:ActionController>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/actionpack-3.2.12/lib/action_controller/base.rb:3:in `<top (required)>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/airbrake-3.1.8/lib/airbrake/railtie.rb:48:in `block in <class:Railtie>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:34:in `call'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:in `each'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
  from /Users/vdp/Sites/DDQ/config/environment.rb:5:in `<top (required)>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
  from /Users/vdp/Sites/DDQ/config.ru:3:in `block in <main>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  from /Users/vdp/Sites/DDQ/config.ru:in `new'
  from /Users/vdp/Sites/DDQ/config.ru:in `<main>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in `app'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
  from /Users/vdp/.rvm/gems/ruby-1.9.3-p392@DDQ/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

由于我真的不确定导致错误的原因,我不确定我应该提供哪些其他输出。任何帮助都会得到真正的赞赏。 [编辑:我已根据要求附上了config.ru和environment.rb。]

config.ru:

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
run DDQ::Application

的environment.rb

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
DDQ::Application.initialize!

application.rb中:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

if defined?(Bundler)
  Bundler.require(*Rails.groups(:assets => %w(development test)))
end

module DDQ
  class Application < Rails::Application

    config.encoding = "utf-8"
    config.filter_parameters += [:password]
    config.active_support.escape_html_entities_in_json = true
    config.active_record.whitelist_attributes = true
    config.assets.enabled = false
    config.assets.version = '1.0'
    %w(middleware sweepers).each do |dir|
      config.autoload_paths << Rails.root.join('app', dir)
    end

    secret_file = Rails.root.join("secret")
    if File.exist?(secret_file)
      secret = File.read(secret_file)
    else
      secret = ActiveSupport::SecureRandom.hex(64)
      File.open(secret_file, 'w') { |f| f.write(secret) }
    end
    config.action_controller.session = {
      :key => '_instant_DDQ_session2',
      :secret      => secret
    }

    ENV['INLINEDIR']="/tmp/ruby.#{ENV['USER']}" unless ENV['OS'] =~ /Windows/

    GIGYA_CONFIG = YAML.load_file(Rails.root.join('config','gigya.yml'))[Rails.env.to_s]

    if defined?(PhusionPassenger)
      PhusionPassenger.on_event(:starting_worker_process) do |forked|
        Rails.cache.clear if forked
      end
    end

  end
end

的Gemfile:

source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'mysql2'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'activemerchant'
gem 'rdiscount'
gem 'calendar_helper'
gem 'devise'
gem 'geokit-rails3'
gem 'will_paginate'
gem 'uuid'
gem 'airbrake'
gem 'paperclip'
gem 'fast_xs'
gem 'thin'
gem 'posix-spawn'

group :test do
  gem 'test-unit'
  gem 'cucumber-rails'
  gem 'capybara'
  gem 'rspec'
  gem 'rspec-rails'
  gem 'database_cleaner'
end

1 个答案:

答案 0 :(得分:0)

尝试更新您的宝石

bundle update