This describes how to create links to static content in a way that works whether or not your app is installed directly at document root, and under other web servers than Webrick.

In a Rails app, static content is placed under the @public@ subdirectory.  Images, Javascripts, and stylesheets are stored in the @public/images@, @public/javascripts@, and @public/stylesheets@ subdirectories.

When running under Webrick, files under the public directory can be accessed using an absolute URL, as in

<pre>
  <img src="/images/someimage.gif"/>
</pre>

However this doesn't work if your app is installed somewhere other than document root, or if running under some other web server than Webrick where you want the web server to handle static content.  For example, if your Rails app is running under Apache/FCGI, and is installed at @/yourapp@ under document root, then the correct URL for your image would need to be

<pre>
  <img src="/yourapp/public/images/someimage.gif"/>
</pre>

Luckily, Rails has some helpers to generate the correct URL automatically regardless of the environment your app is running under.  

* For images, javascript files, and stylesheets, use the @image_tag@, @javascript_include_tag@, and @stylesheet_link_tag@ helper functions respectively.  See the "ActionView::Helpers::AssetTagHelper":http://ap.rubyonrails.com/classes/ActionView/Helpers/AssetTagHelper.html documentation.  For example, to generate the above image tag, you'd write:
<pre><%= image_tag "someimage.gif" %></pre>
and this would generate the correct URL regardless of how the app was deployed.
* For links to other static content, Rails doesn't seem to provide a helper function.  Here's one that you can add to your app/helpers/application_helper.rb file and use similarly to the ones described above:
<pre>
  def link_to_file(name, file, *args)
     if file[0] != ?/
        file = "#{@request.relative_url_root}/#{file}"
     end
     link_to name, file, *args
  end
</pre>
The code 
<pre>
<%= link_to_file "Installer Program", "installer.exe" %>
</pre>
will generate a link like
<pre>
  <a href="/installer.exe">Installer Program</a>
</pre>
under Webrick, and under the Apache setup described above:
<pre>
  <a href="/yourapp/public/installer.exe">Installer Program</a>
</pre>

*QUESTION: Is this any different than "link_to":http://api.rubyonrails.com/classes/ActionView/Helpers/UrlHelper.html#M000331 ?*
