문제

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.

도움이 되었습니까?

해결책

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top