开发者

Home_path issue with RoR testing locally on mobile device

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/


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/


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜