rails 4.1 beta升级'action-view no method error'

时间:2013-12-18 07:37:18

标签: ruby-on-rails upgrade actionview

我正在尝试将rails应用程序从rails 4.0.2升级到4.1 beta,我按照http://edgeguides.rubyonrails.org/4_1_release_notes.html#action-pack-removals上给出的所有说明进行操作。 每当我运行我的应用程序时,这就是我得到的错误

/Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `action_view' for # (NoMethodError)
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/jquery-rails-3.0.4/lib/jquery/rails/railtie.rb:7:in `block in '
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:36:in `call'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:44:in `each'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/application.rb:121:in `initialize'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/railtie.rb:171:in `new'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/railtie.rb:171:in `instance'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/application.rb:90:in `inherited'
    from /Users/surendra/Desktop/faces/config/application.rb:13:in `'
    from /Users/surendra/Desktop/faces/config/application.rb:12:in `'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:79:in `require'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:79:in `block in server'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/surendra/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.1.0.beta1/lib/rails/commands.rb:17:in `'
    from bin/rails:4:in `require'
    from bin/rails:4:in `'

我的application.rb文件就是这个

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

require "action_controller/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"

Bundler.require(:default, Rails.env)

module ElitmusFaces
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de
  end
end

你能帮我解决这个错误,我想知道错误发生的地方

1 个答案:

答案 0 :(得分:10)

我终于解决了这个问题,因为我没有在application.rb中跟踪rails约定,我不得不深入挖掘以找出问题所在。看起来问题是由

引起的
 require "action_controller/railtie"

它显示的错误是,找不到actionview方法。所以我只用

替换了那一行
 require "action_view/railtie"

我收到了这些信息 https://github.com/rails/rails/pull/7356

似乎actionview与actionpack分离,所以我需要自己添加它。