From 8662fd4d3d5ad42de94676afb6a187144c706430 Mon Sep 17 00:00:00 2001 From: Benjamin Guibert Date: Fri, 17 May 2019 17:21:58 +0200 Subject: [PATCH] Replace has_many deprecated ordering --- rails-models.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rails-models.md b/rails-models.md index d215f458..1f1dc235 100644 --- a/rails-models.md +++ b/rails-models.md @@ -247,11 +247,11 @@ Associations belongs_to :parent, :foreign_key => 'parent_id' class_name: 'Folder' has_many :folders, :foreign_key => 'parent_id', class_name: 'Folder' -has_many :comments, :order => "posted_on" +has_many :comments, -> { order('posted_on DESC') } has_many :comments, :include => :author has_many :people, :class_name => "Person" has_many :people, :conditions => "deleted = 0" -has_many :tracks, :order => "position" +has_many :tracks, -> { order(:position) } has_many :comments, :dependent => :nullify has_many :comments, :dependent => :destroy has_many :tags, :as => :taggable