Page Caching appears to cause certain actions to render blank

Hi,

I'm wondering if anyone else has experienced this...

I have a controller with three actions, and I want to cache only the action named index. At the top of the controller I have:

caches_page :index

The index action loads and caches fine, however the other two actions in the controller now render as blank pages. In my development log, i get this:

Processing MyController#blank_page (for 127.0.0.1 at 2007-04-02 17:10:06) [GET]   Session ID: 43b02585893271eaf440ad31061176bf   Parameters: {"action"=>"blank_page", "controller"=>"my"} Filter chain halted as [#<ActionController::Filters::ClassMethods::ProcFilter:0x33d608c @filter=#<Proc:0x033d61e0@(eval):1>>] returned false. Completed in 0.00015 (6797 reqs/sec) | [http://0.0.0.0/my/blank_page\]

I understand that when the filter chain is halted like that, there a before filter returning false for some reason, but I disabled the only before filter I have in the application when this started happening, so I know it's not that returning false.

Stranger still (to me at least), if I change the "caches_page" declaration at the top of the controller to cache all the actions, all the actions render blank, with that same message in the logs.

Any ideas as to what might be happening here? I've gotten this error on Rails 1.2.1 and 1.2.3.

Thanks in advance.

Best, PJ

PJ,

Do you specify in your environment.rb where the cached pages are supposed to be held? Mine looks a little something like this:

config.action_controller.page_cache_directory = RAILS_ROOT + "/public/ cache/"

Sincerely,

Robert Dempsey

Robert,

Thanks for your reply.

Currently, I do specify the following in my environment.rb

config.action_controller.page_cache_directory = RAILS_ROOT+"/public/ cache/"

However, it happens whether or not I do this. This has happened in two other apps of mine where I'm not specifying a custom cache directory.

Any ideas?

Best, PJ

PJ,

One other thing to check is whether or not you have write access to that directory. Also, does caching work in development mode? Can you show come log output for the action? That may help us to figure this out.

- Robert

Hi Robert,

Yeah, permissions seem to be fine. They are set at 755 for the directories in my public folder.

So, to recap what's happening, with a little more detail...In both development and production environments, when I have page caching on the first (index) action, caching works as expected for that action, but all other actions in the controller don't render because something in the Filter Chain is returning false (see log output below). This filter chain returns false in development mode whether or not caching is actually set to true in config/environments/development.rb (the first action doesn't get cached though unless it is set to true).

Thanks so much for your help!

Development Log:

Processing OurFleetController#index (for 127.0.0.1 at 2007-04-03 09:07:56) [GET]   Session ID: 706fe3fcd29909cec43a17d70c1fa2da   Parameters: {"action"=>"index", "controller"=>"our_fleet"} Rendering within layouts/site Rendering our_fleet/index Rendered our_fleet/_includes (0.00182) Rendered our_fleet/_ujs (0.03645) Rendered our_fleet/_jet_thumbs (0.00434) Rendered our_fleet/_jet_thumbs (0.00167) Rendered our_fleet/_jet_thumbs (0.00263) Rendered our_fleet/_jet_thumbs (0.00248) Rendered our_fleet/_jet_thumbs (0.00101) Rendered /layouts/_head (0.00009) Rendered /layouts/_header (0.00040) Rendered /layouts/_menu (0.00213) Rendered /layouts/_sidebar (0.00012) Rendered /layouts/_footer (0.00077) Completed in 0.37697 (2 reqs/sec) | Rendering: 0.06067 (16%) | DB: 0.25131 (66%) | 200 OK [http://0.0.0.0/our_fleet\]

Processing OurFleetController#jet (for 127.0.0.1 at 2007-04-03 09:08:11) [POST]   Session ID: 706fe3fcd29909cec43a17d70c1fa2da   Parameters: {"jet"=>"falcon-2000", "jet_type"=>"full-size", "action"=>"jet", "controller"=>"our_fleet"} Filter chain halted as [#<ActionController::Filters::ClassMethods::ProcFilter:0x3534ab4 @filter=#<Proc:0x03534c30@(eval):1>>] returned false. Completed in 0.00014 (7358 reqs/sec) | DB: 0.00000 (0%) | [http:// 0.0.0.0/our_fleet/full-size/falcon-2000]

Production Log:

Processing OurFleetController#index (for 127.0.0.1 at 2007-04-03 09:00:48) [GET]   Session ID: 706fe3fcd29909cec43a17d70c1fa2da   Parameters: {"action"=>"index", "controller"=>"our_fleet"} Rendering within layouts/site Rendering our_fleet/index Completed in 1.52917 (0 reqs/sec) | Rendering: 0.05797 (3%) | DB: 0.82278 (53%) | 200 OK [http://0.0.0.0/our_fleet\]

Processing OurFleetController#jet (for 127.0.0.1 at 2007-04-03 09:01:08) [POST]   Session ID: 706fe3fcd29909cec43a17d70c1fa2da   Parameters: {"jet"=>"citation-x", "jet_type"=>"super-mid-size", "action"=>"jet", "controller"=>"our_fleet"} Filter chain halted as [#<ActionController::Filters::ClassMethods::ProcFilter:0x35ea2c4 @filter=#<Proc:0x035ea418@(eval):1>>] returned false. Completed in 0.00017 (5882 reqs/sec) | DB: 0.00000 (0%) | [http:// 0.0.0.0/our_fleet/super-mid-size/citation-x]

I finally discovered that the issue was being caused by the unobtrusive javascript plugin. A quick look on their google group revealed a solution. FYI, the fix is in the trunk but not included in the current release.

http://groups.google.com/group/ujs4rails/browse_thread/thread/f93ea937cd8a6c12

Rock. Thank you for sharing that one.

- Robert