Answer the question
In order to leave comments, you need to log in
How to bind js file to action in application controller?
There is an action in the application controller
application_controller.rb
def track_activity(user, trackable, action = params[:action], author = current_user)
Activity.create! user: user, trackable: trackable, action: action, author: author
PrivatePub.publish_to("/messages/new", cool: activity)
end
<% publish_to "/messages/new" do %>
$("#activity").append("<%= j render(@activities) %>");
<% end %>
Answer the question
In order to leave comments, you need to log in
Personally, I have not worked with faye yet, but I recommend the article: habrahabr.ru/post/124066 - you need to write this js code in the faye view so that it sends it to your rails application, in the rails js application itself it can be like this:
$(function() {
var faye = new Faye.Client('http://moesuperprilozhenie.ru:9292/faye');
faye.subscribe("/orders/update", function(data) {
eval(data);
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question