Alon wrote:
Hmm... seems to be querying the database every single time for some reason...
this is how it looks like (categories instead of airlines in this example)
class Category < ActiveRecord::Base
def self.get_categories @@all_categories ||= find(:all, :order => "name") end
def self.expire_categories @@all_categories = nil end end
# in some controller @cat = Category.get_categories # this statement always ends up in a db query
expire_categories is not used yet in my code so nobody is setting it to nil
-- Posted via http://www.ruby-forum.com/.
In development mode, the models get reloaded on each request (IIRC), so the value of @@all_categories gets reset every time you call the page.
_Kevin