peter
March 9, 2008, 2:17pm
1
I’d having my first tries at caching in Rails, and would like to
experiment with fragmentcaching. I have some problems with getting any
results and i don’t know exactly what’s going on now.
I have this in my development.rb…
config.action_controller.perform_caching = true
config.action_controller.cache_store = :file_store,
RAILS_ROOT + “/public/cache/”
and this is my layout-viewfile…
cache “main_menu” do
= render :partial => ‘menu’
I see nothing happening though, and no files appear in public/cache,
so i’m wondering if i overlooked something. The menu-partial loops
through all categories (it has a Category.find(:all).each in it) but i
still see that SQL-query in my terminal.
peter
March 11, 2008, 11:43pm
2
hmmm, i’m getting a
undefined method `cache_fragment’ for #Haml::Template:0x2647a74
when i do that. is haml in the way?
On Mar 10, 1:00 am, Nathan E. <rails-mailing-l…@andreas -
peter
March 12, 2008, 12:41am
3
No, I am developing with HAML and I use fragment caching all the time.
Are you using Rails 2.0.2. It should work like this:
config/environments/development.rb
config.action_controller.perform_caching = true
config.action_controller.fragment_cache_store = [:file_store,
“#{RAILS_ROOT}/tmp/cache”]
app/views/example/something.html.haml
#…
#…
That is how I have it all throughout my app and it seems to work.
peter
March 10, 2008, 1:00am
4
You messed up the cache_store setting a bit.
/config/environments/development.rb
config.action_controller.perform_caching = true
config.action_controller.fragment_cache_store = [:file_store,
“#{RAILS_ROOT}/tmp/cache”]
Then make sure to restart the server.
That really should work as long as the “find” action is contained
directly within the partial and is not done in the controller.
peter
March 12, 2008, 12:43am
5
Make sure you have the latest version of haml as well. Haml 1.8.2