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
on 2007-07-05 23:18
on 2007-07-05 23:35
> 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
on 2007-07-06 02:39
Also - production env have cache set on default.