Question

I've set up a rails app with faye.

It includes the following code parts:

applications.html.haml:

= javascript_include_tag "http://localhost:9292/faye.js"

discussions.js:

$(function() {
  var faye = new Faye.Client('http://localhost:9292/faye');
  faye.subscribe("/messages/new", function(data) {
    eval(data);
  });
});

When I run the app on localhost in dev mode everything works fine. On the VPS server, it tries to reach my "localhost:9292/faye", when it should be the servers localhost.

Q: Is there a method, or way to get it working with the same code on both the server and localhost? Manually changing to the domain isn't looks the rails way.

Was it helpful?

Solution

you can use:

"#{request.protocol}#{request.host_with_port}/faye"

for more info:

How do I get the current absolute URL in Ruby on Rails?

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