Saturday, 17 August 2013

Rails way to put localhost in include tags and javascript

Rails way to put localhost in include tags and javascript

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.

No comments:

Post a Comment