From 2c7ef40867e11dafc79be04f9df45809fbcfb421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Gagn=C3=A9?= Date: Wed, 10 Dec 2014 13:33:30 -0500 Subject: [PATCH] Order menu.links association by position automatically --- app/models/georgia/menu.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/georgia/menu.rb b/app/models/georgia/menu.rb index a8337a6..e654be8 100644 --- a/app/models/georgia/menu.rb +++ b/app/models/georgia/menu.rb @@ -3,7 +3,7 @@ class Menu < ActiveRecord::Base validates :name, presence: true - has_many :links, dependent: :destroy + has_many :links, -> { order(position: :asc) }, dependent: :destroy accepts_nested_attributes_for :links, allow_destroy: true def self.policy_class