views:

120

answers:

3

I have a controller within a namespace and would like to cache it's Index. I am successfully caching pages that are not under a namespace, and successfully caching fragments as well.

When I visit http//.../house/kitchen it successfully creates /public/house/kitchen.html. However it never finds it, so it is always writing over the cached file.

I haven't been able to find an option with cache_page or caches_page to help me direct the cached file in the correct location.

Another frustrating thing is that http//.../house/kitchen/table successfully reads and creates /public/houose/kitchen/table/new.html.

I would greatly appreciate any direction!

Edit: adding details
Ruby : 1.8.7
Rails: 2.3.5
Server: Mongrel

Edit: I've placed kitchen.html in every possible location in my public folder, this controller seems just to refuse reading it.

A: 

My suggestion is to not use namespaces, anything you want to do in regards to urls can be done with routing. Is there a reason why you have to use namespaced controllers?

jonnii
Unfortunately I don't own the app. Once I bang my head against the wall long enough, and can demonstrate that removing the namespacing will resolve the problem, then it's a possibility.
TravisKs
A: 

I am not sure if it is relevant but I found there was an issue with goldspike web server a while ago.
So maybe your web server also is missing something (BTW, what a web server are you using)?

Dmytrii Nagirniak
currently using mongrel. I don't believe this is related as mongrel is successfully doing this with fragments, and page views that are not namespaced.
TravisKs
I do not see obvious reasons looking at http://github.com/rails/rails/blob/master/actionpack/lib/action_controller/caching/pages.rbbut you could give it a try, maybe you'll spot something.Maybe that there is something to do with the web server itself...
Dmytrii Nagirniak
A: 

I think I'm having the same issue. If so, I know the cause, but haven't yet found a solution.

The web server finds the directory http://…/house/kitchen/ before it finds the file http://…/house/kitchen.html. This directory doesn't contain an index.html, so it passes the route to Rails which kindly generates a new file.

So, you could:

  1. Place your cached file at http://…/house/kitchen/index.html

  2. Tell your web server to look for *.html files before it looks for */ directories.

Andy