diff --git a/app/models/comment.rb b/app/models/comment.rb index c2ff4c37c..cd24a5c0b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -65,7 +65,7 @@ class Comment < ApplicationRecord end def update_last_commented_at_on_destroy - other_comments = Comment.where("post_id = ? and id <> ?", post_id, id).order("id DESC") + other_comments = Comment.where("post_id = ? and id <> ?", post_id, id).order(id: :desc) if other_comments.count == 0 Post.where(:id => post_id).update_all(:last_commented_at => nil) else diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 17ea1d6f9..3c2aa39ee 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -127,7 +127,7 @@ class ForumPost < ApplicationRecord end def update_topic_updated_at_on_delete - max = ForumPost.where(:topic_id => topic.id, :is_deleted => false).order("updated_at desc").first + max = ForumPost.where(topic_id: topic.id, is_deleted: false).order(updated_at: :desc).first if max ForumTopic.where(:id => topic.id).update_all(["updated_at = ?, updater_id = ?", max.updated_at, max.updater_id]) end @@ -140,7 +140,7 @@ class ForumPost < ApplicationRecord end def update_topic_updated_at_on_destroy - max = ForumPost.where(:topic_id => topic.id, :is_deleted => false).order("updated_at desc").first + max = ForumPost.where(topic_id: topic.id, is_deleted: false).order(updated_at: :desc).first if max ForumTopic.where(:id => topic.id).update_all(["response_count = response_count - 1, updated_at = ?, updater_id = ?", max.updated_at, max.updater_id]) else diff --git a/app/models/news_update.rb b/app/models/news_update.rb index 2bb0b9a5b..394cfe4d3 100644 --- a/app/models/news_update.rb +++ b/app/models/news_update.rb @@ -3,7 +3,7 @@ class NewsUpdate < ApplicationRecord belongs_to :creator, class_name: "User" belongs_to_updater - scope :recent, -> {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)} + scope :recent, -> {where("created_at >= ?", 2.weeks.ago).order(created_at: :desc).limit(5)} def self.visible(user) if user.is_admin? diff --git a/app/models/post.rb b/app/models/post.rb index a041f3c26..4eeddc8b1 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -983,11 +983,11 @@ class Post < ApplicationRecord end def random_up(key) - where("md5 < ?", key).reorder("md5 desc").first + where("md5 < ?", key).reorder(md5: :desc).first end def random_down(key) - where("md5 >= ?", key).reorder("md5 asc").first + where("md5 >= ?", key).reorder(md5: :asc).first end def sample(query, sample_size) diff --git a/app/models/saved_search.rb b/app/models/saved_search.rb index 501ae8173..8baa748fd 100644 --- a/app/models/saved_search.rb +++ b/app/models/saved_search.rb @@ -90,7 +90,7 @@ class SavedSearch < ApplicationRecord def labels_for(user_id) SavedSearch .where(user_id: user_id) - .order("label") + .order(label: :asc) .pluck(Arel.sql("distinct unnest(labels) as label")) end end diff --git a/app/models/tag.rb b/app/models/tag.rb index eb5222d79..402953306 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -295,11 +295,11 @@ class Tag < ApplicationRecord case params[:order] when "name" - q = q.order("name") + q = q.order(name: :asc) when "date" - q = q.order("id desc") + q = q.order(id: :desc) when "count" - q = q.order("post_count desc") + q = q.order(post_count: :desc) when "similarity" q = q.order_similarity(params[:fuzzy_name_matches]) if params[:fuzzy_name_matches].present? else diff --git a/app/models/user.rb b/app/models/user.rb index 714904faa..7a55daa9d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -657,13 +657,13 @@ class User < ApplicationRecord case params[:order] when "name" - q = q.order("name") + q = q.order(name: :asc) when "post_upload_count" - q = q.order("post_upload_count desc") + q = q.order(post_upload_count: :desc) when "note_count" - q = q.order("note_update_count desc") + q = q.order(note_update_count: :desc) when "post_update_count" - q = q.order("post_update_count desc") + q = q.order(post_update_count: :desc) else q = q.apply_default_order(params) end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 444aba459..aa491e9a6 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -94,7 +94,7 @@ class WikiPage < ApplicationRecord case params[:order] when "title" - q = q.order("title") + q = q.order(title: :asc) when "post_count" q = q.includes(:tag).order("tags.post_count desc nulls last").references(:tags) else