actioncable

ActionCable.server.broadcast from the console

梦想与她 提交于 2019-11-29 02:51:30
I can use the following code in the controller but not in the console (both development environment). I'm using Rails 5.0.0.beta2. ActionCable.server.broadcast 'example_channel', message: '<p>Test</p>' The console: >> ActionCable.server.broadcast 'example_channel', message: '<p>Test</p>' [ActionCable] Broadcasting to example_channel: {:message=>"<p>Test</p>"} => [] How can I use it in the console? The default behavior for ActionCable in development mode is to use the async adapter, which operates within the same process only. For inter-process broadcasting, you will need to switch to the redis

How To use devise_token_auth with ActionCable for authenticating user?

守給你的承諾、 提交于 2019-11-28 05:37:44
问题 I have a Rails 5 API with devise_token_auth gem authentications. Now I want personal chat for authenticated users. I do not have assets as I am using API and front is in native apps and I want native apps messaging. So how I can authenticate users to use action cable for personal messaging using devise_token_auth gem 回答1: No cookies are generally supported in Rails 5 API. See: http://guides.rubyonrails.org/api_app.html#creating-a-new-application . If you do a common HTTP-authentification at

ActionCable - how to display number of connected users?

五迷三道 提交于 2019-11-27 21:25:18
I'm trying to create a simple chat-like application (planning poker app) with Action Cable. I'm a little bit confused by the terminology, files hierarchy and how the callbacks work. This is the action that creates user session: class SessionsController < ApplicationController def create cookies.signed[:username] = params[:session][:username] redirect_to votes_path end end A user can then post a vote that should be broadcasted to everyone: class VotesController < ApplicationController def create ActionCable.server.broadcast 'poker', vote: params[:vote][:body], username: cookies.signed[:username

Request origin not allowed: http://localhost:3001 when using Rails5 and ActionCable

微笑、不失礼 提交于 2019-11-27 14:34:36
Having server issues with an app in Rails 5.0.0.beta2 trying to use ActionCable. Using localhost:3000 works fine, as that is what most of ActionCable defaults to. But if I try to run the rails server on port 3001, it gives me Request origin not allowed: http://localhost:3001 The ActionCable docs mention using something like ActionCable.server.config.allowed_request_origins = ['http://localhost:3001'] which does work for me if I put it in config.ru But that seems like a really weird place to put it. I feel like it should be able to go in an initializer file, or my development.rb environment

How to use ActionCable as API

≡放荡痞女 提交于 2019-11-27 12:49:15
I built a very simple app using Rails 5 beta 1 and ActionCable to show when users come online and let them send messages to each other. Now, I would basically like to take the client-side part of ActionCable, implement it in the context of another app (that does not run on Rails 5) and connect it with the first app to send and receive data (such as the online status of users or messages). To send data from that second app, I assume, I can simply make an AJAX POST request. The question is: How do I subscribe from my second app to an open connection of the first app? Or even: How do I subscribe

How do I find out who is connected to ActionCable?

和自甴很熟 提交于 2019-11-27 03:22:19
问题 I have seen ActionCable.server.open_connections_statistics , ActionCable.server.connections.length , ActionCable.server.connections.map(&:statistics) , ActionCable.server.connections.select(&:beat).count and the like, however this is only "per process" (server, console, server worker, et cetera). How do I find out everyone who is subscribed to ActionCable at this time? This should return the same value on any Rails process in each environment (development, staging, production). So for example

ActionCable.server.broadcast from the console

◇◆丶佛笑我妖孽 提交于 2019-11-27 03:02:54
问题 I can use the following code in the controller but not in the console (both development environment). I'm using Rails 5.0.0.beta2. ActionCable.server.broadcast 'example_channel', message: '<p>Test</p>' The console: >> ActionCable.server.broadcast 'example_channel', message: '<p>Test</p>' [ActionCable] Broadcasting to example_channel: {:message=>"<p>Test</p>"} => [] How can I use it in the console? 回答1: The default behavior for ActionCable in development mode is to use the async adapter, which

Request origin not allowed: http://localhost:3001 when using Rails5 and ActionCable

时光毁灭记忆、已成空白 提交于 2019-11-26 16:48:45
问题 Having server issues with an app in Rails 5.0.0.beta2 trying to use ActionCable. Using localhost:3000 works fine, as that is what most of ActionCable defaults to. But if I try to run the rails server on port 3001, it gives me Request origin not allowed: http://localhost:3001 The ActionCable docs mention using something like ActionCable.server.config.allowed_request_origins = ['http://localhost:3001'] which does work for me if I put it in config.ru But that seems like a really weird place to

How to use ActionCable as API

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 16:08:39
问题 I built a very simple app using Rails 5 beta 1 and ActionCable to show when users come online and let them send messages to each other. Now, I would basically like to take the client-side part of ActionCable, implement it in the context of another app (that does not run on Rails 5) and connect it with the first app to send and receive data (such as the online status of users or messages). To send data from that second app, I assume, I can simply make an AJAX POST request. The question is: How