簡體   English   中英

Rails 4.2.3`method_missing':未定義的方法`active_record'

[英]Rails 4.2.3 `method_missing': undefined method `active_record'

我今天嘗試創建一個新的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

球面寶石的6.0.1版本似乎導致了此問題,它已於2015年7月10日更新。 https://rubygems.org/gems/arel/versions/6.0.1

==更新==

作者今天早上以6.0.2解決了這個問題。 https://github.com/rails/arel/issues/375

跑:

bundle update

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM