ActionCable:为什么将广播放在单独的工作中?对于为什么不从控制器广播的表格? [英] ActionCable: Why put broadcasts in a separate job? For forms why not broadcast from controllers?

查看:165
本文介绍了ActionCable:为什么将广播放在单独的工作中?对于为什么不从控制器广播的表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大部分的教程是在一年前推出的DHH示例应用程序的版本略有更改。他们中的大多数人都喜欢将广播投入工作。但是A)这不是Redis的一点吗? B)由于我使用Delayed :: Job不会直接播放更快?

Most of the tutorials out there are slightly altered versions of an example app DHH put out over a year ago. Most of them share the habit of moving broadcasting out into a job. But A) Isn't that the point of Redis already? B) Since I'm using Delayed::Job wouldn't it just be faster to broadcast directly?

创建模型或通过ActionCable提交表单时,它不会似乎没有CSRF保护。是否积极限制起源消除了对protect_from_forgery的需求?宝石的自述文件有一个教程的链接,它添加了一个签名的cookie,我看到另一个教程 found_verified_user warden ['env']。 。这是否解决了 protect_from_forgery 解决的问题?

When creating a model, or submitting a form through ActionCable it doesn't seem to have CSRF protection. Does actively restricting the origins eliminate the need for protect_from_forgery? The gem's Readme has a link to a tutorial which adds a signed cookie, and I saw another tutorial which finds_verified_user from warden['env'].user. Does this address the problem that protect_from_forgery solves?

如果没有:我以为我可以将表单提交给控制器,然后直接从控制器广播给所有订阅的用户?但是,由于它看起来很简单,但是我没有看到任何我担心的地方有一些理由。有没有?

And if not: I thought I could submit the form to the controller as usual and then broadcast to all the subscribed users direct from the controller?But since it seems so simple but I haven't seen that anywhere I'm worried there's some reason. Is there?

推荐答案

只要能够给这个问题一个答案,这里是一个Heroku教程,使用我想要的相同的建筑理念使用。所以,从设计的角度来看,它似乎不再是反模式了。

Just to be able to give this question an answer here's a Heroku tutorial using the same architectural idea that I want to use. So, from a design standpoint it doesn't seem like an anti-pattern anymore

https://blog.heroku.com/real_time_rails_implementing_websockets_in_rails_5_with_action_cable#step-2-broadcast-to-the-channel

这篇关于ActionCable:为什么将广播放在单独的工作中?对于为什么不从控制器广播的表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆