@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Serve static html file with assets at both production and development

The best way to serve static html pages at Rails 3 is using asset pipeline. An article Precompile Static HTML Pages with Rails 3 Asset Pipeline describes how to do it.

By the way, asset pipeline is a mechanism for production environment, so the above solution is not fit for development environment.

I figured out a solution of this problem. I created StaticPagesController. The action of this controller renders static html pages by render with :file option.



Then you can see a rendered sample.html.erb page both at production and development. In production, you can access to this page via URL like http://example.com/assets/sample.html. In development (with pow), you can access to this page via URL like http://example.dev/static_pages/sample.

I think I have to do more optimization for this solution, but it works well.