possibly better fix for ordering pools by category

This commit is contained in:
Toks
2013-05-15 01:09:18 -04:00
parent fb4ce9a13b
commit 633bc8cb31
2 changed files with 6 additions and 5 deletions

View File

@@ -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?

View File

@@ -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)