From 633bc8cb311bfc4a81210d59fa3f52ac828f91bf Mon Sep 17 00:00:00 2001 From: Toks Date: Wed, 15 May 2013 01:09:18 -0400 Subject: [PATCH] possibly better fix for ordering pools by category --- app/models/pool.rb | 4 ++++ app/presenters/post_presenter.rb | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/pool.rb b/app/models/pool.rb index 7c01e45d2..8994a0e36 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -29,6 +29,10 @@ class Pool < ActiveRecord::Base where("category = ?", "collection") end + def series_first + order("(case category when 'series' then 0 else 1 end), name") + end + def search(params) q = scoped params = {} if params.blank? diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 140d2e067..04577fc72 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -161,16 +161,13 @@ class PostPresenter < Presenter return if pool.nil? html += pool_link_html(template, pool, :include_rel => true) - other_pools = @post.pools.active.where("id <> ?", template.params[:pool_id]) - other_pools = other_pools.series + other_pools.collection - + other_pools = @post.pools.active.where("id <> ?", template.params[:pool_id]).series_first other_pools.each do |other_pool| html += pool_link_html(template, other_pool) end else - pools = @post.pools.active - pools = pools.series + pools.collection first = true + pools = @post.pools.active.series_first pools.each do |pool| if first && template.params[:tags].blank? html += pool_link_html(template, pool, :include_rel => true)