Frage

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.

War es hilfreich?

Lösung

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?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top