I am trying to optimize some methods in my model so they don’t repeat
CPU intensive algorithms every time I call the method in the same
request/response cycle.
Eg.
def invitations
all_pgm_updates.find_all do |update|
update.invited?
end
end
I want to do something like:
def invitations
if @invitations.nil?
@invitations = all_pgm_updates.find_all do |update|
update.invited?
end
end
@invitations
end
but isn’t the instance variable, @invitations, going to stick around
as long as the record is stored in the session? How do I clear it at
the beginning of every request? Models don’t have access to flash, I
don’t think, so I need an alternative.
-John
–
John S.
Computing Staff - Webmaster
Kavli Institute for Theoretical Physics
University of California, Santa Barbara
[email protected]
(805) 893-6307