diff options
| author | hukl <contact@smyck.org> | 2009-03-28 18:20:02 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-03-28 18:20:02 +0100 |
| commit | ce140a7fc8eb6bea5a567e7c6681087db0055fb4 (patch) | |
| tree | b6460e87956cbd90523c09f860bcb631e0d85b84 | |
| parent | 1b149d03320bd08f0977201b5662343707e15975 (diff) | |
introducing named scope :drafts for Page
| -rw-r--r-- | app/controllers/admin_controller.rb | 6 | ||||
| -rw-r--r-- | app/models/page.rb | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 81a3809..d61de30 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb | |||
| @@ -2,11 +2,7 @@ class AdminController < ApplicationController | |||
| 2 | before_filter :login_required | 2 | before_filter :login_required |
| 3 | 3 | ||
| 4 | def index | 4 | def index |
| 5 | @drafts = Page.find( | 5 | @drafts = Page.drafts |
| 6 | :all, | ||
| 7 | :include => [:node, :user, :globalize_translations], | ||
| 8 | :conditions => ["nodes.draft_id = pages.id"] | ||
| 9 | ) | ||
| 10 | end | 6 | end |
| 11 | 7 | ||
| 12 | end | 8 | end |
diff --git a/app/models/page.rb b/app/models/page.rb index 45a05dc..0bebb84 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -5,6 +5,14 @@ class Page < ActiveRecord::Base | |||
| 5 | PUBLIC_TEMPLATE_PATH = File.join(%w(custom page_templates public)) | 5 | PUBLIC_TEMPLATE_PATH = File.join(%w(custom page_templates public)) |
| 6 | FULL_PUBLIC_TEMPLATE_PATH = File.join(RAILS_ROOT, 'app', 'views', PUBLIC_TEMPLATE_PATH) | 6 | FULL_PUBLIC_TEMPLATE_PATH = File.join(RAILS_ROOT, 'app', 'views', PUBLIC_TEMPLATE_PATH) |
| 7 | 7 | ||
| 8 | # named scopes | ||
| 9 | |||
| 10 | named_scope( | ||
| 11 | :drafts, | ||
| 12 | :include => [:node, :user, :globalize_translations], | ||
| 13 | :conditions => ["nodes.draft_id = pages.id"] | ||
| 14 | ) | ||
| 15 | |||
| 8 | # Mixins and Plugins | 16 | # Mixins and Plugins |
| 9 | acts_as_taggable | 17 | acts_as_taggable |
| 10 | acts_as_list :column => :revision, :scope => :node_id | 18 | acts_as_list :column => :revision, :scope => :node_id |
