Getting fragment-caching to work...

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.

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.

hmmm, i'm getting a

undefined method `cache_fragment' for #<Haml::Template:0x2647a74>

when i do that. is haml in the way?

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

#...
- cache(:controller => "example", :action => "something") do
  <div id="some_section">
    this section will be cached
  </div>
#...

That is how I have it all throughout my app and it seems to work.

Make sure you have the latest version of haml as well. Haml 1.8.2