From 85b60ee48a4c9973d4bc52aacddaa62491ab16ed Mon Sep 17 00:00:00 2001 From: hukl Date: Mon, 30 Mar 2009 21:29:18 +0200 Subject: added named scope for heads --- app/models/page.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app') diff --git a/app/models/page.rb b/app/models/page.rb index dfabecf..b2c0ff8 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -13,6 +13,12 @@ class Page < ActiveRecord::Base :conditions => ["nodes.draft_id = pages.id"] ) + named_scope( + :heads, + :include => [:node, :user, :globalize_translations], + :conditions => ["nodes.head_id = pages.id"] + ) + # Mixins and Plugins acts_as_taggable acts_as_list :column => :revision, :scope => :node_id -- cgit v1.3 From acc9301696de3589a17d1543a7ab3fc1914e8ce8 Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 7 Apr 2009 22:03:46 +0200 Subject: made this line a little easier to understand. thanks to @handtwerk --- app/models/node.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/node.rb b/app/models/node.rb index 8b7fe62..b56dff5 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -88,7 +88,7 @@ class Node < ActiveRecord::Base # returns array with pages up to root excluding root def path_to_root - parent.nil? && [slug] || parent.path_to_root.push(slug) + parent.nil? ? [slug] : parent.path_to_root.push(slug) end def update_unique_name -- cgit v1.3