In my rails application (v2.3.8), I have a static resource file that I put in /public/myfile.kml. Is route.rb correct for any special settings?
It is great for http: // localhost: 3000 / myfile.kml
When I deploy (for the passenger), it appears at http: //myserver/myappname/myfile.kml
Everything is fine so far ...
I have a view (erb file) that outputs javascript that should reference this file. The output should be "/myfile.kml" on localhost and "/myappname/myfile.kml" during production, or possibly the full URL as above, or perhaps the relative URL containing the bit ".. /../../'(comfortable with RESTful URLs).
Should I do something like <% = url_for 'myfile.kml'%>?
or '<% = ROOT_URL%> /myfile.kml'
I know there is an insanely easy answer to this question, but honestly, I was not lucky to find it. Quite a lot of people talk about root_url, but what is it? A variable that I can refer to in a view? It is undefined.
ruby-on-rails-2
Harry wood
source share