2016-01-21 27 views
11

Używam Rails 5 z actioncable i otrzymuję this error podczas próby wysłania czegokolwiek, co rzuca actioncable Co powinienem zrobić? Próbuję przenieść projekt do Heroku.Szyny 5 Actioncable undefined Metoda `Fetch 'for Nil: NilClass

NoMethodError in MessagesController#create 

undefined method `fetch' for nil:NilClass 
Extracted source (around line #37): 

#35  # Also makes sure proper dependencies are required. 
#36  def pubsub_adapter 
*37   adapter = (cable.fetch('adapter') { 'redis' }) 
#38   path_to_adapter = "action_cable/subscription_adapter/#{adapter}" 
#39   begin 
#40   require path_to_adapter 

Extracted source (around line #50): 

#48  # Adapter used for all streams/broadcasting. 
#49  def pubsub 
*50   @pubsub ||= config.pubsub_adapter.new(self) 
#51  end 
#52 
#53  # All the identifiers applied to the connection class associated with this server. 

Extracted source (around line #42): 

#40   def broadcast(message) 
#41    server.logger.info "[ActionCable] Broadcasting to #{broadcasting}: #{message}" 
*42    server.pubsub.broadcast broadcasting, ActiveSupport::JSON.encode(message) 
#43   end 
#44   end 
#45  end 


Rails.root: /media/adham/Data/code/rails5test 

Application Trace 
app/controllers/messages_controller.rb:6:in `create' 
app/middleware/chat_action_cable.rb:10:in `call' 
+0

Wygląda na to, że 'cable' jest' nil' po wywołaniu 'cable.fetch'. Czy tak jest? –

Odpowiedz

15

Było zobowiązać się tutaj: enter link description here

Czytając i zmieniając plik konfiguracyjny dla ActionCable od ...

config/redis/cable.yml

do

config/cable.yml

... naprawiono problem. Ta aktualizacja ma umożliwiać agnostikowanie mechanizmu ActionCable.

+0

dziękuję za pracę: D –

+1

Czy ktoś może wyjaśnić, dlaczego tak się dzieje? Zdarzyło mi się to również z Railsami 5.0.0.beta2 – ftshtw

+0

Zmienili plik konfiguracyjny, by był bardziej niejednoznaczny dla backendu ActionCable, zamiast domyślnie Redis. –