possibly better fix for ordering pools by category
This commit is contained in:
@@ -29,6 +29,10 @@ class Pool < ActiveRecord::Base
|
|||||||
where("category = ?", "collection")
|
where("category = ?", "collection")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def series_first
|
||||||
|
order("(case category when 'series' then 0 else 1 end), name")
|
||||||
|
end
|
||||||
|
|
||||||
def search(params)
|
def search(params)
|
||||||
q = scoped
|
q = scoped
|
||||||
params = {} if params.blank?
|
params = {} if params.blank?
|
||||||
|
|||||||
@@ -161,16 +161,13 @@ class PostPresenter < Presenter
|
|||||||
return if pool.nil?
|
return if pool.nil?
|
||||||
html += pool_link_html(template, pool, :include_rel => true)
|
html += pool_link_html(template, pool, :include_rel => true)
|
||||||
|
|
||||||
other_pools = @post.pools.active.where("id <> ?", template.params[:pool_id])
|
other_pools = @post.pools.active.where("id <> ?", template.params[:pool_id]).series_first
|
||||||
other_pools = other_pools.series + other_pools.collection
|
|
||||||
|
|
||||||
other_pools.each do |other_pool|
|
other_pools.each do |other_pool|
|
||||||
html += pool_link_html(template, other_pool)
|
html += pool_link_html(template, other_pool)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
pools = @post.pools.active
|
|
||||||
pools = pools.series + pools.collection
|
|
||||||
first = true
|
first = true
|
||||||
|
pools = @post.pools.active.series_first
|
||||||
pools.each do |pool|
|
pools.each do |pool|
|
||||||
if first && template.params[:tags].blank?
|
if first && template.params[:tags].blank?
|
||||||
html += pool_link_html(template, pool, :include_rel => true)
|
html += pool_link_html(template, pool, :include_rel => true)
|
||||||
|
|||||||
Reference in New Issue
Block a user