From 7e46b0ce0f2216d4a53cf9e633fcfed3cd421c7c Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 1 Dec 2009 21:05:45 +0100 Subject: refactored the Page.aggregate to instanciate a lot less AR objects. Its actually instanciating only the ones being displayed. Still over 150 but still a massive improvement compared to over 1500 before. --- app/models/page.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index 00832bd..37b221e 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -62,15 +62,17 @@ class Page < ActiveRecord::Base options = defaults.merge options - Page.heads.find_tagged_with( - options[:tags].gsub(/\s/, ", "), - :match_all => true, - :order => "#{options[:order_by]} #{options[:order_direction]}" - ).paginate(:page=>page, :per_page => options[:limit]) - + Page.heads.paginate( + find_options_for_find_tagged_with( + options[:tags].gsub(/\s/, ","), :match_all => true + ).merge( + :page => page, + :per_page => options[:limit], + :order => "#{options[:order_by]} #{options[:order_direction]}" + ) + ) end - def self.custom_templates files = Dir.entries(FULL_PUBLIC_TEMPLATE_PATH).select do |x| x if x.gsub!(".html.erb", "") -- cgit v1.3