From ce140a7fc8eb6bea5a567e7c6681087db0055fb4 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 28 Mar 2009 18:20:02 +0100 Subject: introducing named scope :drafts for Page --- app/controllers/admin_controller.rb | 6 +----- 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 before_filter :login_required def index - @drafts = Page.find( - :all, - :include => [:node, :user, :globalize_translations], - :conditions => ["nodes.draft_id = pages.id"] - ) + @drafts = Page.drafts end 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 PUBLIC_TEMPLATE_PATH = File.join(%w(custom page_templates public)) FULL_PUBLIC_TEMPLATE_PATH = File.join(RAILS_ROOT, 'app', 'views', PUBLIC_TEMPLATE_PATH) + # named scopes + + named_scope( + :drafts, + :include => [:node, :user, :globalize_translations], + :conditions => ["nodes.draft_id = pages.id"] + ) + # Mixins and Plugins acts_as_taggable acts_as_list :column => :revision, :scope => :node_id -- cgit v1.3