geoff swartz
geoff swartz

Reputation: 5977

serving static content outside of public directory in rails

I have a folder in the root of my rails 4.1.1 project called coverage that shows all of my test coverage. I was hoping to set up a route to get to this, but since it's not in the public folder, it doesn't work. I have the following route defined...

get '/rspec', :to => redirect('/coverage/index.html')

Is this possible to do? If so, how? Thanks.

Upvotes: 2

Views: 936

Answers (2)

Sean Huber
Sean Huber

Reputation: 3985

To do this you can use Rack::Static by adding this to your config/application.rb:

config.middleware.use Rack::Static, :urls => ['/coverage'], :root => Rails.root.to_s

Upvotes: 1

infused
infused

Reputation: 24367

You could symlink the coverage directory into your public directory

ln -nfs coverage public/coverage

Upvotes: 0

Related Questions