0

I have a lot of html pages on my site that are static, but I serve them dynamically through the typical rails controller & view setup just because I want to use my application.html.erb layout and not have to worry about changing it in multiple places if I just cut and paste it into a static html file I put in my public directory.

I recently upgraded to Rails 3.2 however, and the asset pipeline and its precompiling of assets sounded like a perfect fit for this problem. However, I have not seen any good documentation on how to write a *.html.erb asset, and direct it to use application.html.erb, or any other layout for that matter. can someone post how to do this, or point me to a good resource? Thanks!

Mohamed Hafez
  • 8,621
  • 7
  • 41
  • 49

1 Answers1

0

Instead of trying to serve the static html partials through the asset pipeline, have you thought about just caching them?

If what your worried about is actually getting the static partial to be rendered then you might want to try the following in your view. The following would be for your nav.

-cache 'main-nav' do
  =render :partial => 'layouts/nav'

This way on the first load it would retrieve your partial, and all subsequent loads it would retrieve it from your cache, which if you have redis or memcache set up, should make it blazing fast.

rovermicrover
  • 1,453
  • 1
  • 15
  • 21