Christoffer
Christoffer

Reputation: 26865

Rails3: Serve a file statically that is not in "public/"

How do I serve a file statically with the correct content-type headers if it is not (for good reason) in the "public/" directory?

Upvotes: 1

Views: 629

Answers (2)

Gareth
Gareth

Reputation: 138210

Rails has a send_file method which will do this

Upvotes: 1

yfeldblum
yfeldblum

Reputation: 65455

See Rack::Static.

module MyApp
  class Application < Rails::Application
    config.middleware.use Rack::Static,
      :urls => [ '/my-secret-dir' ],
      :root => 'my/secret/dir'
  end
end

Upvotes: 1

Related Questions