views:

85

answers:

2

When I use

<%= link_to image_tag("foo.png"), home_path %>

and display it on my localhost on my iPhone, it's broken. When I inspect on with firebug, the src of the image is http://localhost:3000/images/foo.png thus causing it to break on my iPhone.

When I use

<img src="/images/foo.png" />

it displays fine on my iPhone. I am pointing to the IP address of my PC running the server of my rails app in Safari. It's loading the text but all the css, JavaScript, and images are missing unless the path is absolute with using the rails default helpers.

Is there a way to correct this path issue locally so it's absolute like /images/foo.png instead of http://localhost:3000/images/foo.png.

Update

CSS file paths are also affected. Instead of just making the path /stylesheets/foo.css, it's http://localhost:3000/stylesheets/foo.css.

Update: Solution

It's the Facebook plugin changing the asset host to the callback url of my facebook app settings which is currently set to http://localhost:3000/

A: 

It's the facebooker plugin changing the asset host to the callback url of my facebook app settings which is currently set to http://localhost:3000/

Amir
A: 

I was facing a similar issue until a few minutes back in my rails app that was using facebooker plugin where all asset routes were being overwritten. the symptom of this was errors like

ActionController::RoutingError (No route matches "/runfbrun//stylesheets/facebooker.css" with {:method=>:get, :canvas=>false}):

I finally fixed it by setting this value set_asset_host_to_callback_url: false in my /config/facebooker.yml

  • Note- for heroku apps this ha to be in the production: section of the facebooker.yml
mataal