actioncable

User Session Authentication in Rails 5

余生长醉 提交于 2019-12-24 09:29:45
问题 I am trying to implement notification using the action cable in Rails 5. After reading the tutorial for the Action cable, which work on the session & Cookies based Authentication to receive the notification for the current logged in user. module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user logger.add_tags 'ActionCable', current_user.username end protected def find_verified_user if verified_user

ActionCable: Why put broadcasts in a separate job? For forms why not broadcast from controllers?

倖福魔咒の 提交于 2019-12-24 09:13:46
问题 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? 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

how to use ruby in a js assets file? (undefined method 'body')

China☆狼群 提交于 2019-12-24 05:55:05
问题 I'm following this tutorial and having a problem where using ruby in an ActionCable file causes an undefined method 'body' error. How can I use ruby in this file? I want the data that's submitted over Action Cable to be properly formatted when it is appended, and I cannot do that with plain js. This is my app/assets/js/channels/messages.js.erb file: App.messages = App.cable.subscriptions.create('MessagesChannel', { received: function(data) { $("#response").val(""); $('#messages').append(this

Possible to mount multiple ActionCable cables?

人盡茶涼 提交于 2019-12-23 18:20:55
问题 Is it possible to mount multiple ActionCable cables in the same Rails application? For example as such: #routes.rb Rails.application.routes.draw do ... mount ActionCable.server => '/cable' mount ActionCable.server => '/cable2' end I am aware I can have multiple channels using the same cable , but I require to use different authentication methods for my channels. From my understanding, this is not possible using the same cable. Thanks for your help. 回答1: As elaborated in Using ActionCable with

Does Action Cable 5 require Redis?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 10:15:26
问题 I use: rails (5.0.2) actioncable (5.0.2) puma (3.8.2) I have a Rails 5 Action Cable demo chat and a year ago it didn't work without Redis - and now it does! (after bundle update ). In other words, I succedeed to make my demo chat to work in development mode without Redis . I set the config/cable.yml like this: development: adapter: async test: adapter: async production: adapter: async and start rails c . That's it - the chat is working, no problem. So Redis is obviously not needed anymore -

How to set params when subscribing to Action Cable channel

拟墨画扇 提交于 2019-12-23 09:47:51
问题 I've been trying to get my head around action cable for what seems like months. Please help. I have a "Connection" - I can't set the identified_by :current_user because this endpoint also needs to be consumed by an external API that uses WebSockets. Can't use browser cookies to authenticate the API endpoint. Files & Support Connection: /app/channels/application_cable/connection.rb module ApplicationCable class Connection < ActionCable::Connection::Base end end Channel: /app/channels

ActionCable usage in Rails 5 RESTful API Development?

社会主义新天地 提交于 2019-12-23 03:43:09
问题 I am trying to create a RESTful API for the first time. Sending Request(Client to Server) and Response(Server to Client) using Action Cable. How to send request from other Applications(like Android/iOS App, Web App'n or Desktop App'n) and give response to the application. I have used Action Cable in normal Web Application. Please provide me some links with guides of ActionCable usage in Rails 5 RESTful API. Thanks in Advance. 回答1: Here is the detail to use Action Cable as Restful API. Use

Disable rails log for ActionCable events

流过昼夜 提交于 2019-12-22 03:16:48
问题 In development environment, rails logger logs all ActionCable events which is sometimes annoying (for my project, every now and then it's transmitting messages and log tail is running like wild horse). What is an efficient way to suppress all event logs from ActionCable? Also, how can I suppress some specific ActionCable events? 回答1: To completely disable logging from ActionCable you should configure ActionCable to use logger that do nothing ActionCable.server.config.logger = Logger.new(nil)

How to configure ActionCable with Nginx and Unicorn in production?

醉酒当歌 提交于 2019-12-20 10:58:13
问题 I've recently switched my rails project from Rails4 to 5.0.0.beta3 to use the awesome ActionCable. My ActionCable server is run inside unicorn. In development all works fine. In production I have Started GET "/cable" for xxx.xxx.xxx.xxx at 2016-03-28 18:06:38 +0300 Started GET "/cable/" [WebSocket] for xxx.xxx.xxx.xxx at 2016-03-28 18:06 Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket) Registered connection (189772ff-6229-48f1-ae7f

RoR 5.0.0 ActionCable wss WebSocket handshake: Unexpected response code: 301

自闭症网瘾萝莉.ら 提交于 2019-12-19 05:59:17
问题 Hello I'm trying to serve a simple chat using ror 5.0.0 beta (with puma) working on production mode (in localhost there are no problems). This is my Nginx configuration: upstream websocket { server 127.0.0.1:28080; } server { listen 443; server_name mydomain; ssl_certificate ***/server.crt; ssl_certificate_key ***/server.key; ssl on; ssl_session_cache builtin:1000 shared:SSL:10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; ssl