Forum: Ruby on Rails Layouts being cached?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aaron (Guest)
on 2007-07-06 01:18
(Received via mailing list)
I'm working on my spin of the age old shopping cart app.  To help
customers focus on checking out it seems reasonable enough to give
them a simpler layout while they're doing so.  I added the following
code to my app.  You can assume that @mysession.checking_out? is
functioning correctly and returns either true or false depending on
the users state at present.  It is well tested.

So in development this works like a charm, no problems.  Once I move
it into production, the layout used is correctly selected the first
hit, but all subsequent hits to that particular controller/action
combination use that same layout regardless of state.

Production environment settings have not been altered, I'm not using
any form of caching.

If you have any idea what is going on I'd appreciate your insight.

Here's the Code:-----------------
class ApplicationController < ActionController::Base
...
before_filter :checkout?
...
  def checkout?
    #if we are checking out and this isn't a checkout activity but it
is a get request, then...
...
    if @mysession.checking_out?
      self.class.layout "checkout"
    end
...
end
--------------

Thanks,
Aaron
Philip H. (Guest)
on 2007-07-06 01:35
(Received via mailing list)
> combination use that same layout regardless of state.
> ...
>  def checkout?
>    #if we are checking out and this isn't a checkout activity but it
> is a get request, then...
> ...
>    if @mysession.checking_out?
>      self.class.layout "checkout"

else
   self.class.layout "the normal one"
end

Rails saves the layout you define at the class level when it first
reads/loads that class.  So once you switch it, it's never switching
back.

-philip
nextpulse (Guest)
on 2007-07-06 04:39
(Received via mailing list)
Also - production env have cache set on default.
This topic is locked and can not be replied to.