Hi all,
Whilst building a Single Page App that needs to serve the same static file for a number of routes, and have those routes available as URL helpers (for mail templates and tests primarily), I’m using this technique that allows static files to be declared in routes.rb like so:
Rails.application.routes.draw do
…
This route will serve public/index.html at the /login URL path, and have
URL helper named login_path:
get “/login”, to: static(“index.html”)
This route will serve public/index.html at the /register URL path, and
have URL helper named new_user_registration_path:
get “/register”, to: static(“index.html”), as: :new_user_registration
…
end
Source and setup instructions: GitHub - eliotsykes/rails-static-router: Enjoy static routes in your Rails config/routes.rb
I would appreciate any feedback and if this would be a welcome contribution to actionpack.
Kindest regards,
Eliot