Rails 7: How to embed an existing HTML site in a rails app while maintaining authentication

Viewed 20

I have to embed an existing HTML project (a directory that was exported from another service including HTML files, gifs, and pngs) in a Rails app. These files should only be viewable by authenticated users, so I can't put them in /public.

Do I have to write a controller and convert all the existing HTML files (of which there are many) to rails views to get all the routing and auth to work and serve the assets via the asset pipeline? Or am I missing a less time-intensive solution? I'm worried that the HTML may change not-infrequently and I don't want to get stuck replicating this process often.

1 Answers

If you did not need to authenticate the user, then you would be able to serve them over the /public folder. But I think you will need controllers since you want to authenticate.

You will need to create controllers and views. It should not be too hard as you won't need to do a lot of custom erb.

Then just add a authenticate user before method to all pages you wanted authentication for.

Related