Search code examples
ruby-on-railsruby-on-rails-3websocketrailscastsfaye

private pub - publish from controller never works


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?


Solution

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