From 876fe2363cfd35562b5475510584d810a10d35a7 Mon Sep 17 00:00:00 2001 From: Bijal Patel Date: Thu, 10 May 2018 10:22:23 -0700 Subject: [PATCH] Connect to database if not connected --- lib/closure_tree/support_flags.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/closure_tree/support_flags.rb b/lib/closure_tree/support_flags.rb index 043e785f..2819d324 100644 --- a/lib/closure_tree/support_flags.rb +++ b/lib/closure_tree/support_flags.rb @@ -17,8 +17,8 @@ def order_option? end def order_is_numeric? - # skip if database is not connected. - return false unless ::ActiveRecord::Base.connected? + # connect to database if it is not connected. + ::ActiveRecord::Base.connection unless ::ActiveRecord::Base.connected? # The table might not exist yet (in the case of ActiveRecord::Observer use, see issue 32) return false if !order_option? || !model_class.table_exists?