Topic: Rails 3.1: How do I access a file in my /public folder?

I'm trying to embed a Unity3D webplayer, named webplayer.unity3d, object using some javascript that is in my application.html.erb layout file...

 if (typeof unityObject != "undefined")
     unityObject.embedUnity("unityPlayer", "webplayer.unity3d", 960, 640);

the route for the page that I'm trying to access is /pages/fb, so when I go to, it doesn't load the webplayer.unity3d file. When I check the logs, it says...

ActionController::RoutingError (No route matches [GET] "/pages/webplayer.unity3d"):

As I understand the new assets pipeline, access to any files in the public folder should remain the same. How can I access this webplayer.unity3d file in my /public folder?

Thanks so much in advance for your wisdom!

Re: Rails 3.1: How do I access a file in my /public folder?

Roughly speaking, you have to replace



<%= asset_path('webplayer.unity3d') %>

If that original bit if javascript you posted is in your view in a <script type='text/javascript'></script>  tag,  you should be good to go.

If it's in a separate javascript file file in app/assets/javascripts,  you have to change it's extension, for example:




Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.