我在heroku上遇到动作电缆问题。操作电缆正常工作正在广播更新,但是每当我从系统执行任何更新时,数据似乎都是缓存。
情况:
db sample(在postgres上):
产品has_many项目
它在本地唯一的heroku制作问题上运行正常。它随机出现(每次重新加载页面时都会改变)
以下是我的文件:
宝石:
ruby "2.3.1"
gem 'puma', '~> 3.9', '>= 3.9.1'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'redis', '~> 3.3', '>= 3.3.3'

cable.yml
development:
adapter: redis
url: redis://localhost:6379/1
test:
adapter: async
production:
adapter: redis
url: <%= ENV["REDIS_URL"] %>
&#13;
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the rails generate channel command.
//
//= require action_cable
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer();
}).call(this);
&#13;
信道/ connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
end
private
def find_verified_user
verified_user = User.find_by(id: cookies.signed['user.id'])
if verified_user
verified_user
else
reject_unauthorized_connection
end
end
end
end
&#13;
信道/ web_notifications_channel.rb
# channel/web_notifications_channel.rb
class WebNotificationsChannel < ApplicationCable::Channel
def subscribed
stream_from "web_notifications_#{current_user.id}"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
def speak(data)
end
end