13

サーバーを実行しているときに、以下のログに表示されるエラーがスローされます。私はたくさんグーグルで検索しましたが、その背後にある理由はわかりませんでした。誰か光を当ててください。

Gemfile

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '>= 5.0.0.beta1', '< 5.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'

gem 'active_model_serializers', '~> 0.10.0.rc1'

group :development, :test do
  gem 'byebug'
end
gem 'puma'
group :development do
  gem 'spring'
end

ログ:

/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/server/configuration.rb:15:in
`initialize': uninitialized constant
ActionCable::Server::Configuration::ApplicationCable (NameError)    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/server/base.rb:16:in `new'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/server/base.rb:16:in `block in <class:Base>'    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta1/lib/active_support/core_ext/module/attribute_accessors.rb:72:in
`block in mattr_reader'     from
/home/pd/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta1/lib/active_support/core_ext/module/attribute_accessors.rb:55:in
`each'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta1/lib/active_support/core_ext/module/attribute_accessors.rb:55:in
`mattr_reader'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta1/lib/active_support/core_ext/module/attribute_accessors.rb:208:in
`mattr_accessor'    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/server/base.rb:16:in `<class:Base>'     from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/server/base.rb:12:in `<module:Server>'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/server/base.rb:7:in
`<module:ActionCable>'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/server/base.rb:6:in
`<top (required)>'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable.rb:43:in
`server'    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/actioncable-5.0.0.beta1/lib/action_cable/process/logging.rb:10:in
`<top (required)>'  from /home/pd/Documents/EventsApp/config.ru:7:in
`block in <main>'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/builder.rb:55:in
`instance_eval'     from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/builder.rb:55:in
`initialize'    from /home/pd/Documents/EventsApp/config.ru:in `new'
    from /home/pd/Documents/EventsApp/config.ru:in `<main>'     from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/builder.rb:49:in
`eval'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/builder.rb:49:in
`new_from_string'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/builder.rb:40:in
`parse_file'    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/server.rb:318:in
`build_app_and_options_from_config'     from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/server.rb:218:in
`app'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands/server.rb:56:in
`app'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/rack-2.0.0.alpha/lib/rack/server.rb:353:in
`wrapped_app'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands/server.rb:134:in
`log_to_stdout'     from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands/server.rb:74:in
`start'     from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands/commands_tasks.rb:90:in
`block in server'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands/commands_tasks.rb:85:in
`tap'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands/commands_tasks.rb:85:in
`server'    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands/commands_tasks.rb:49:in
`run_command!'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/command.rb:20:in
`run'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta1/lib/rails/commands.rb:19:in
`<top (required)>'  from /home/pd/Documents/EventsApp/bin/rails:9:in
`require'   from /home/pd/Documents/EventsApp/bin/rails:9:in `<top
(required)>'    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/spring-1.6.0/lib/spring/client/rails.rb:28:in
`load'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/spring-1.6.0/lib/spring/client/rails.rb:28:in
`call'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/spring-1.6.0/lib/spring/client/command.rb:7:in
`call'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/spring-1.6.0/lib/spring/client.rb:28:in
`run'   from
/home/pd/.rvm/gems/ruby-2.2.4/gems/spring-1.6.0/bin/spring:51:in `<top
(required)>'    from
/home/pd/.rvm/gems/ruby-2.2.4/gems/spring-1.6.0/lib/spring/binstub.rb:11:in
`load'  from
/home/pd/.rvm/gems/ruby-2.2.4/gems/spring-1.6.0/lib/spring/binstub.rb:11:in
`<top (required)>'  from /home/pd/Documents/EventsApp/bin/spring:13:in
`require'   from /home/pd/Documents/EventsApp/bin/spring:13:in `<top
(required)>'    from bin/rails:3:in `load'  from bin/rails:3:in `<main>'
4

5 に答える 5

17

このエラーは、プロジェクトに正しい ActionCable ファイルがないことに関連しています。あなたはapp/channels/application_cable/channel.rbこのように見える必要があります

module ApplicationCable
  class Channel < ActionCable::Channel::Base
  end
end

app/channels/application_cable/connection.rb

module ApplicationCable
  class Connection < ActionCable::Connection::Base
  end
end
于 2016-01-12T01:06:58.717 に答える
17

以前のバージョンからアップグレードした場合 (actioncable がバンドルに含まれていなかった場合)、config/application.rb含まれているかどうかを確認します。

require "action_cable/engine"
于 2018-03-02T01:40:09.530 に答える
9

Rails 4.2.5 で ActionCable を使用しようとしたときに同じ問題が発生しました。解決策は、config/application.rb に以下を追加することでした。

config.autoload_paths += %W(#{config.root}/app/channels)

これは ActionCable gem の場合です:

gem 'actioncable', github: 'rails/actioncable', branch: 'archive'
于 2016-01-27T11:12:31.640 に答える
0

また、以下を追加することで、Heroku の展開に関する問題を解決します。

require "action_cable/engine"

config/application.rb

于 2021-02-18T00:02:06.920 に答える