views:

155

answers:

1

For assets stored in the 'public' folder of a ruby-on-rails application is it possible to change the 'Content-Type' when running 'script/server'? For example, I am attempting to create an HTML5 application supporting offline mode, and have an 'offline.manifest'. When I run:

curl -I localhost:3000/offline.mainfest

The following header information is returned:

HTTP/1.1 200 OK
...
Content-Type: text/plain
...

However, HTML5 specifications require:

HTTP/1.1 200 OK
...
Content-Type: text/cache-manifest
...
+1  A: 

Good question. I'd suggest digging into Rails::Rack::Static which is what serves files out of public these days.

Alternatively you could write a controller-action to serve just this filetype. Serve them up using send_file and pass the type explicitly eg:

send_file params[:filename], :type => 'text/cache-manifest'

http://apidock.com/rails/ActionController/Streaming/send_file

Taryn East
Thanks. I tried using the Rails::Rack::Static but ended up using the second option.
Kevin Sylvestre