diff options
| author | hukl <contact@smyck.org> | 2009-02-27 16:08:31 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-27 16:08:31 +0100 |
| commit | ed5168e4c98ec7d4af6bceaa25d0a36c2777cc5d (patch) | |
| tree | 2a225846b712125165d17d2380eda49ef49c35cf | |
| parent | 7aa907ca4190efd807a368f8ed7668abd536832d (diff) | |
modified the aggregate method to take only head / published pages into account
| -rw-r--r-- | app/models/page.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index aba974a..ec2198c 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -21,21 +21,26 @@ class Page < ActiveRecord::Base | |||
| 21 | # The Page.aggregate method comes with a defaults hash. These options are | 21 | # The Page.aggregate method comes with a defaults hash. These options are |
| 22 | # partially or entirely overwritten by the options hash. Afterwards the merged | 22 | # partially or entirely overwritten by the options hash. Afterwards the merged |
| 23 | # parameters are used to query the DB for Pages matching these parameters. | 23 | # parameters are used to query the DB for Pages matching these parameters. |
| 24 | # The aggregation only takes published pages into account. | ||
| 24 | def self.aggregate options | 25 | def self.aggregate options |
| 25 | 26 | ||
| 26 | defaults = { | 27 | defaults = { |
| 27 | :tags => "", | 28 | :tags => "", |
| 28 | :limit => 20, | 29 | :limit => 20, |
| 29 | :order_by => "id", | 30 | :order_by => "pages.id", |
| 30 | :order_direction => "ASC" | 31 | :order_direction => "ASC" |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | options = defaults.merge options | 34 | options = defaults.merge options |
| 34 | 35 | ||
| 35 | pages = Page.find_tagged_with( | 36 | pages = Page.find_all_tagged_with( |
| 36 | options[:tags].gsub(/\s/, ", "), | 37 | options[:tags].gsub(/\s/, ", "), |
| 37 | :match_all => true, | 38 | :match_all => true, |
| 38 | :order => "#{options[:order_by]} #{options[:order_direction]}") | 39 | :order => "#{options[:order_by]} #{options[:order_direction]}", |
| 40 | :include => :node, | ||
| 41 | :conditions => ["nodes.head_id = pages.id"] | ||
| 42 | ) | ||
| 43 | |||
| 39 | end | 44 | end |
| 40 | 45 | ||
| 41 | # Instance Methods | 46 | # Instance Methods |
