Serve static files in Rails

This shows a way to mount a directory from which Rails will serve static files. By default, path/ will serve index.html if present.

# In routes.rb
mount ActionDispatch::Static.new(
  Rails.application,
  Rails.root.join('some/directory').to_s
), at: '/path'

Code snippets in this post are covered by 0BSD License.



Date
August 1, 2023