uninitialized constant > ActionCable::Server::Configuration::ApplicationCable
Asked Answered
K

5

15

When I am running server its throwing error shown in logs below. I googled a lot but didn't get reason behind it. Somebody please put some light on it.

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

Logs:

/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>'
Katheleenkatherin answered 21/12, 2015 at 12:43 Comment(2)
I'm having this issue as soon as I try to mount it with routes ´mount ActionCable.server => '/cable'´Behave
@Behave Look at my answer below, it should solve your problem.Puppis
P
17

The error is related to not having the correct ActionCable files in your project. You need app/channels/application_cable/channel.rb that looks like this

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

and app/channels/application_cable/connection.rb

module ApplicationCable
  class Connection < ActionCable::Connection::Base
  end
end
Puppis answered 12/1, 2016 at 1:6 Comment(1)
This solved my issue too. I upgraded a 4.x.x project to 5.x.x to use action cable, and this was one of the items missing when following the early tutorials for a new 5.x.x project.Bilge
Z
19

If you upgraded from previous version (when actioncable was not in the bundle), check if config/application.rb contains

require "action_cable/engine"
Zombie answered 2/3, 2018 at 1:40 Comment(0)
P
17

The error is related to not having the correct ActionCable files in your project. You need app/channels/application_cable/channel.rb that looks like this

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

and app/channels/application_cable/connection.rb

module ApplicationCable
  class Connection < ActionCable::Connection::Base
  end
end
Puppis answered 12/1, 2016 at 1:6 Comment(1)
This solved my issue too. I upgraded a 4.x.x project to 5.x.x to use action cable, and this was one of the items missing when following the early tutorials for a new 5.x.x project.Bilge
C
9

I had the same problem when trying to use ActionCable with Rails 4.2.5 and the solution was to add the following to config/application.rb:

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

This is with the ActionCable gem:

gem 'actioncable', github: 'rails/actioncable', branch: 'archive'
Capillarity answered 27/1, 2016 at 11:12 Comment(0)
R
3

According to DHH's video tutorial from yesterday, there's an issue between Spring and an ActionCable dependency, so until the final release of Rails 5 you will need to recreate your project with the --skip-spring option.

Regolith answered 21/12, 2015 at 13:46 Comment(5)
Thanks for the response, but that didn't work. Same error.Katheleenkatherin
Just a sanity check: did you run bundle after removing it from the Gemfile? :-)Regolith
Removing Spring from gemfile didn't worked, but yes after --skip-spring in new rails app its working fine.Katheleenkatherin
This is not the correct answer as spring has nothing to do with this problem. The error is raised b/c the ApplicationCable module is missing. The spring problem is a totally different problem related to celluloid not being reloadable (and does therefore not work with spring). The reason --skip-spring seams to work on a blank project is b/c the files I suggested below already exists. -1Puppis
@PardeepDhingra Take a look at my answer below, it should solve your problem.Puppis
A
2

I also solve the problem with Heroku deployment by adding the following:

require "action_cable/engine"

in config/application.rb

Apollonian answered 18/2, 2021 at 0:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.