Move all order logic to models

- Have a default order for each model
-- The overall default is ID DESC
- Allow for custom orderings
-- When comma-separated IDs are used
This commit is contained in:
BrokenEagle
2018-01-28 20:46:18 -08:00
parent f83480cc8a
commit d829ab3a00
49 changed files with 134 additions and 116 deletions

View File

@@ -67,7 +67,6 @@ class ForumPost < ApplicationRecord
def search(params)
q = super
q = q.permitted
return q if params.blank?
if params[:creator_id].present?
q = q.where("forum_posts.creator_id = ?", params[:creator_id].to_i)
@@ -93,7 +92,7 @@ class ForumPost < ApplicationRecord
q = q.joins(:topic).where("forum_topics.category_id = ?", params[:topic_category_id].to_i)
end
q
q.apply_default_order(params)
end
end