Prevent caching of helper method

Hi,
I have a helper method to get a date from a cookie (in application
helper) that looks like this:

def getToday
if(cookies[:date])
cookies[:date].to_date
else
Date.today
end
end

I set the cooke date using a before_filter method in the application
controller, reading a GET param:

before_filter :save_today_as_cookie

def save_today_as_cookie

if params[:d]
  cookies.delete :date
  cookies[:date] = {
    :value => params[:d],
    :expires => 1.hours.from_now
  }
end

end

This works fine, but if I want to change the date by passing a new
date parameter, I have to reload the page twice that it takes affect.

The cookie changes instantly. It seems to me, that the result of the
helper function is cached for one more load.
Setting expiring headers or etags did not help.

I’m using Rails 2.3.2 and no special cache plugin/gem/configuration.

Regards,

Chris

On May 31, 11:12 am, Chris [email protected] wrote:

The cookie changes instantly. It seems to me, that the result of the
helper function is cached for one more load.
Setting expiring headers or etags did not help.

It’s not your helper function, it’s the cookies method:
https://rails.lighthouseapp.com/projects/8994/tickets/2733

Fred

Ah, thanks for the hint. So I’ll have to update the actionpack/lib/
action_controller/base/cookies.rb file, right?

Or what is the recommended way to fix problems in the rails core? (I’m
pretty new to rails)

Regards,

Chris

On May 31, 3:37 pm, Chris [email protected] wrote:

I mean is there a way to patch/overwrite this using a plugin or
something? I don’t want to touch the core classes, if not necessary.

You could just monkey patch it using the patch on that ticket as a
guide.

Fred

I mean is there a way to patch/overwrite this using a plugin or
something? I don’t want to touch the core classes, if not necessary.

Ah, I see. Thanks!

On May 31, 4:57 pm, Frederick C. [email protected]