Question

Trying to implement a simple notification system based on private pub ( something like juggernaut ). by Ryan bates see: http://railscasts.com/episodes/316-private-pub

Problem: Im unable to send a message true private pub from a controller

Some code:

inside header.haml

= subscribe_to "/notifications"
= javascript_include_tag APP_CONFIG['faye'] ( includes JS wich is correct )

inside application.coffee

PrivatePub.subscribe "/notifications", (data, channel) ->
alert data

inside any controller action

PrivatePub.publish_to("/notifications", "some test data to send")

-

This does not work, wanted behavior is that the "some test data to send " is being displayed in an alert on any page I'm on in the rails app. Ive tried several times the tutorial on rails cast, cloned the private pub example code repo, but nothing works sending from a controller.

UPDATE:

Anyone could help provide a example of private pub app in a repro publishing to a channel from a controller?

UPDATE2 It seems as long as there is a create action it works, but without a create action it is not. I would like to be able to just send some data from anywhere in a controller to the app with a javascript command. Like " send private pub message load popup " for example, what do i Missi n above code that makes this not work?

Was it helpful?

Solution

I finally fixed the issues, since no real answers I grant to Brandon if thats possible

OTHER TIPS

Private Pub doesn’t allow you to send messages through the controller. Instead you should respond with a JavaScript that does that on the client. It's all described in this great Faye and PrivatePub tutorial

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top