Question about code reuse and session variables

hey there,

i have a simple model called key_words.rb
the purpose of this is to hold system config data.
it also holds the parameters that our system uses to judge the
condition of the stuff we monitor.

anyway, one of the methods is this

def self.get_in_wet_list(status)
wet_list = find(:first,
:conditions => "name = ‘wet_list’ ")
wet_list.message.split(’,’).include?(status)

end

my question is… we use this to process a lot of information,
sometimes a few thousand records
will go thru this and i think it could be a performance killer.
i wanted to make this a session variable so that it would not have to
go to the database and redraw it a few thousand times on a page
refresh.

so i thought
def self.get_in_wet_list(status)
wet_list = session[:wet_list]
if wet_list.nil?
wet_list = find(:first,
:conditions => "name = ‘wet_list’ ")
end
wet_list.message.split(’,’).include?(status)
end

the only thing is that a model does not seem to be able to access
session variables.

at any rate, does someone have an idea about how to make this work
better ?

thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs