Rails 4.2.3`method_missing&#39 ;: undefined method`active_record'

时间:2015-07-11 07:49:20

标签: ruby-on-rails ruby

我今天尝试创建一个新的Rails应用程序,该应用程序表现得好像ActiveRecord根本就不存在。

我创建了应用程序:

rails new myapp --database=mysql

运行rake db:create时,我得到:

rake aborted!
NoMethodError: undefined method `active_record' for #<Rails::Application::Configuration:0x007faad08b3058>
/Library/Ruby/Gems/2.0.0/gems/railties-4.2.3/lib/rails/railtie/configuration.rb:95:in `method_missing'
/Users/richard/Dropbox/Development/myapp/config/application.rb:24:in `<class:Application>'
/Users/richard/Dropbox/Development/myapp/config/application.rb:10:in `<module:Myapp>'
/Users/richard/Dropbox/Development/myapp/config/application.rb:9:in `<top (required)>'
/Users/richard/Dropbox/Development/myapp/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

事实上,如果我注释掉违规行,然后运行rake -T:

...
rake cache_digests:dependencies         # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_c...
rake cache_digests:nested_dependencies  # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_commen...
rake doc:app                            # Generate docs for the app -- also available doc:rails, doc:guides (options: TEM...
rake log:clear                          # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=t...
rake middleware
...

根本没有rake db:*任务!

我有很多其他Rails应用程序,从Rails 3.x到Rails 4.2.0,它们都运行良好。它只是这个应用程序,今天(和任何新应用程序)创建,显示此行为。

运行OSX 10.10,Ruby 2.0.0,完全存储Gemfile。

application.rb中:

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

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Myapp
  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

    # Do not swallow errors in after_commit/after_rollback callbacks.
    config.active_record.raise_in_transactional_callbacks = true
  end
end

1 个答案:

答案 0 :(得分:1)

isl gem的6.0.1版本似乎导致了这个问题,它于昨天7/10/15更新。 https://rubygems.org/gems/arel/versions/6.0.1

==更新==

作者今天上午用6.0.2解决了这个问题。 https://github.com/rails/arel/issues/375

执行命令

bundle update