links always go to 'localhost'

This could be something to do with how you reference your hrefs in your rails apps. Could you paste one of your hrefs please?