[Rails] Action caching: how to prevent cached request being wrapped with layout when originally rendered with :layout => false
Hi all,
I've run into a problem with action caching in Rails 3.2.1 and am
wondering if anyone can shed some light on the situation.
We are using caches_action with :layout => false for the #show action
on our controller.
The code for the action sometimes renders with the layout, and
sometimes without, eg:
if request.xhr?
render :action => "different_action", :layout => false
else
# render with layout
end
Subsequent cached requests to the code path where we originally
rendered :layout => false are now rendered with the layout. It seems
what Rails is doing is seeing that you didn't cache the layout
originally, and therefore wrapping each subsequent request with the
standard layout. What we want is for the layout not to be rendered.
This caching was (allegedly) working correctly in Rails 2.3, but I
haven't looked into the old ActionController caching code yet to see
how/why.
How should this sort of action be cached so that subsequent requests
don't wrap the cached action body in the layout?
Cheers,
-Jonathan.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home