1

私は非常に長い間使用してきた Rails アプリケーションで作業していますが、この時点までフロントエンドはありませんでした。長い間とは、1年以上を意味します。コンソールベースのデータベースを実行するために使用します。

現在、単純なフロントエンドである json API を配置しようとしていますが、ホームページ、users#index、または localhost:3000 にアクセスしようとするとこのエラーが発生するため、これまでのところ失敗しています。エラーは次のとおりです (いくつかの警告があるため、webrick の起動情報を含めます)。

    => Booting WEBrick
    => Rails 4.0.0 application starting in development on http://0.0.0.0:3000
    => Run `rails server -h` for more startup options
    => Ctrl-C to shutdown server
    config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:

      * development - set it to false
      * test - set it to false (unless you use a tool that preloads your test environment)
      * production - set it to true

    [2015-08-06 10:38:59] INFO  WEBrick 1.3.1
    [2015-08-06 10:38:59] INFO  ruby 2.2.1 (2015-02-26) [x86_64-darwin14]
    [2015-08-06 10:38:59] INFO  WEBrick::HTTPServer#start: pid=2842 port=3000
    DEPRECATION WARNING: You didn't set config.secret_key_base. Read the upgrade documentation to learn more about this new config option. (called from service at /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138)


    Started GET "/" for 127.0.0.1 at 2015-08-06 10:39:01 -0400

    TypeError (wrong argument type Class (expected Module)):
      app/controllers/application_controller.rb:1:in `<top (required)>'
      app/controllers/users_controller.rb:1:in `<top (required)>'

これが私のGemfileです。Rails の新しいバージョンが私のコードの一部を壊しているため、Rails のバージョンを凍結しました。

source 'https://rubygems.org'

gem 'nori' #XML TO JSON
gem 'rubillow'

gem 'rails', '4.0.0' #locked version May 25, 2015
gem 'protected_attributes'


## activerecord etc
  gem 'pg'
  gem 'activerecord-postgis-adapter'
  gem 'squeel', '1.2.3'
  gem 'rgeo', '0.3.20' #locked version May 25, 2015
  gem 'nice-ffi'
  gem 'rgeo-shapefile', '0.2.3' #locked version May 25, 2015
  gem 'rgeo-geojson', '0.3.1' #locked version May 25, 2015
  gem 'geocoder', :git => "https://github.com/ddd1600/geocoder.git"
  gem 'georuby' #for parsing kml
## command line related
  gem 'highline'
  gem 'awesome_print'

これが私のroutes.rbファイルです。かなりバニラです:

PostgisRails::Application.routes.draw do
  #resources :users
  root :to => "users#index"
end

SO でこれと同様のエラー メッセージを確認しましたが、私の状況、つまりすべてが非常にバニラ/デフォルトである状況とまったく同じものは見つかりませんでした。

エラーは、大規模なコードベースのどこかで ActionController と継承または混合 (モンキー パッチ) されたコードに関係していると考えています。ただし、私が知っているモンキーパッチはすべて初期化フォルダーにあり、一時的に削除してもエラーが発生します。

必要な追加情報をお知らせください。提供いたします。ありがとう

追加情報

  • rails sサーバーの起動に使用しています

これが私のapplication.rbファイルです

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

require 'rails/all'
require 'highline/import'
require 'active_record/connection_adapters/postgis_adapter/railtie'

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

module PostgisRails
  class Application < Rails::Application
    config.autoload_paths += Dir["#{config.root}/lib/**/"]
    config.autoload_paths += Dir["#{config.root}/app/modules/**/"]
    config.autoload_paths += Dir["#{config.root}/app/_misc/*.rb"]    
    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 = true
    config.assets.version = '1.0'
  end
end

そして、私は常に開発モードにいるので、ここに私の development.rb ファイルがあります

PostgisRails::Application.configure do
  config.cache_classes = false
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  config.action_mailer.raise_delivery_errors = false
  config.active_support.deprecation = :log
  config.action_dispatch.best_standards_support = :builtin
  config.assets.compress = false
  config.assets.debug = true
end

バグの完全なトレースは次のとおりです。

    actionpack (4.0.0) lib/abstract_controller/helpers.rb:165:in `include'
    actionpack (4.0.0) lib/abstract_controller/helpers.rb:165:in `block in add_template_helper'
    actionpack (4.0.0) lib/abstract_controller/helpers.rb:165:in `module_eval'
    actionpack (4.0.0) lib/abstract_controller/helpers.rb:165:in `add_template_helper'
    actionpack (4.0.0) lib/abstract_controller/helpers.rb:95:in `block in helper'
    actionpack (4.0.0) lib/abstract_controller/helpers.rb:94:in `each'
    actionpack (4.0.0) lib/abstract_controller/helpers.rb:94:in `helper'
    actionpack (4.0.0) lib/action_controller/railties/helpers.rb:17:in `inherited'
    app/controllers/application_controller.rb:1:in `<top (required)>'
    activesupport (4.0.0) lib/active_support/dependencies.rb:423:in `load'
    activesupport (4.0.0) lib/active_support/dependencies.rb:423:in `block in load_file'
    activesupport (4.0.0) lib/active_support/dependencies.rb:615:in `new_constants_in'
    activesupport (4.0.0) lib/active_support/dependencies.rb:422:in `load_file'
    activesupport (4.0.0) lib/active_support/dependencies.rb:323:in `require_or_load'
    activesupport (4.0.0) lib/active_support/dependencies.rb:462:in `load_missing_constant'
    activesupport (4.0.0) lib/active_support/dependencies.rb:183:in `const_missing'
    app/controllers/users_controller.rb:1:in `<top (required)>'
    activesupport (4.0.0) lib/active_support/dependencies.rb:423:in `load'
    activesupport (4.0.0) lib/active_support/dependencies.rb:423:in `block in load_file'
    activesupport (4.0.0) lib/active_support/dependencies.rb:615:in `new_constants_in'
    activesupport (4.0.0) lib/active_support/dependencies.rb:422:in `load_file'
    activesupport (4.0.0) lib/active_support/dependencies.rb:323:in `require_or_load'
    activesupport (4.0.0) lib/active_support/dependencies.rb:462:in `load_missing_constant'
    activesupport (4.0.0) lib/active_support/dependencies.rb:183:in `const_missing'
    activesupport (4.0.0) lib/active_support/inflector/methods.rb:226:in `const_get'
    activesupport (4.0.0) lib/active_support/inflector/methods.rb:226:in `block in constantize'
    activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `each'
    activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `inject'
    activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `constantize'
    activesupport (4.0.0) lib/active_support/dependencies.rb:534:in `get'
    activesupport (4.0.0) lib/active_support/dependencies.rb:565:in `constantize'
    actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:76:in `controller_reference'
    actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:66:in `controller'
    actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:44:in `call'
    actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
    actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
    actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
    actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
    rack (1.5.3) lib/rack/etag.rb:23:in `call'
    rack (1.5.3) lib/rack/conditionalget.rb:25:in `call'
    rack (1.5.3) lib/rack/head.rb:11:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
    rack (1.5.3) lib/rack/session/abstract/id.rb:225:in `context'
    rack (1.5.3) lib/rack/session/abstract/id.rb:220:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
    activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
    activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
    activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__338496911207587002__call__callbacks'
    activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
    actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
    railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
    railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
    activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
    activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
    activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
    railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
    rack (1.5.3) lib/rack/methodoverride.rb:21:in `call'
    rack (1.5.3) lib/rack/runtime.rb:17:in `call'
    activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
    rack (1.5.3) lib/rack/lock.rb:17:in `call'
    actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
    railties (4.0.0) lib/rails/engine.rb:511:in `call'
    railties (4.0.0) lib/rails/application.rb:97:in `call'
    rack (1.5.3) lib/rack/lock.rb:17:in `call'
    rack (1.5.3) lib/rack/content_length.rb:14:in `call'
    rack (1.5.3) lib/rack/handler/webrick.rb:60:in `service'
    /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
    /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
    /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

application.rbに追加config.eager_load = trueして、ホームページにアクセスしようとする前にサーバーを起動しようとすると、すぐにクラッシュしました。これがそのスタックトレースです。

    => Booting WEBrick
    => Rails 4.0.0 application starting in development on http://0.0.0.0:3000
    => Run `rails server -h` for more startup options
    => Ctrl-C to shutdown server
    Exiting
    /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/abstract_controller/helpers.rb:165:in `include': wrong argument type Class (expected Module) (TypeError)
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/abstract_controller/helpers.rb:165:in `block in add_template_helper'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/abstract_controller/helpers.rb:165:in `module_eval'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/abstract_controller/helpers.rb:165:in `add_template_helper'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/abstract_controller/helpers.rb:95:in `block in helper'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/abstract_controller/helpers.rb:94:in `each'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/abstract_controller/helpers.rb:94:in `helper'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/actionpack-4.0.0/lib/action_controller/railties/helpers.rb:17:in `inherited'
        from /Users/daviddouglas/Develop/postgis_rails/app/controllers/application_controller.rb:1:in `<top (required)>'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `load'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `block in load_file'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in `new_constants_in'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:in `load_file'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in `require_or_load'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:288:in `depend_on'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:206:in `require_dependency'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
        from /Users/daviddouglas/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /Users/daviddouglas/Develop/postgis_rails/config/environment.rb:5:in `<top (required)>'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /Users/daviddouglas/Develop/postgis_rails/config.ru:3:in `block in <main>'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:55:in `instance_eval'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:55:in `initialize'
        from /Users/daviddouglas/Develop/postgis_rails/config.ru:in `new'
        from /Users/daviddouglas/Develop/postgis_rails/config.ru:in `<main>'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:49:in `eval'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:49:in `new_from_string'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:40:in `parse_file'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/server.rb:277:in `build_app_and_options_from_config'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/server.rb:199:in `app'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in `app'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/server.rb:314:in `wrapped_app'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/commands/server.rb:75:in `start'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/commands.rb:78:in `block in <top (required)>'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
        from /Users/daviddouglas/.rvm/gems/ruby-2.2.1/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
4

1 に答える 1

1

app/helpersフォルダー内のヘルパーがすべてクラスではなくモジュールであることを確認してください。例:

app/helpers/application_helper.rb は次のようになります。

module ApplicationHelper
end

いいえ

class ApplicationHelper
end

Concernまた、たとえばクラスに何かを含める場合は、クラスではなくモジュールとして定義する必要があります

于 2015-08-22T16:06:18.770 に答える