On 11-04-20 09:00 PM, Domizio Demichelis wrote:

    Is this a known issue or is it worth putting together a test case?


Not completetly sure, but by the way you describe it it might be a bug.
Please, could you post a bare working app ( in good working condition)
and the steps to reproduce the problem?


I just ran into something similar.

To reproduce:

git clone https://github.com/Hobo/agility-gitorial.git -b foo
cd agility-gitorial
bundle install
rake db:migrate --trace

Could not find table 'tasks'.

Backtrace indicates problem is probably at dryml_generator.rb:198.

            klass.new.position_column == refl.options[:order].to_s

It's the klass.new that's failing.

I've attached a patch. It always returns false if the table does not exist, so in a way it returns "incorrect" results for sortable tables that haven't been created yet, but on the other hand, you can't sort a table that doesn't exist.

Gripping hand: it doesn't matter, we're never doing any real work without any tables.

Bryan

--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

>From 5d71aea271ca973bce2fcf919199b27d77592481 Mon Sep 17 00:00:00 2001
From: Bryan Larsen <[email protected]>
Date: Thu, 21 Apr 2011 09:03:53 -0400
Subject: [PATCH] Fix:  sortable? causes an exception when the table does not exist.

---
 dryml/lib/dryml/dryml_generator.rb |    1 +
 hobo/lib/hobo/model/view_hints.rb  |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/dryml/lib/dryml/dryml_generator.rb b/dryml/lib/dryml/dryml_generator.rb
index 3e0f1e3..7f4a9fd 100644
--- a/dryml/lib/dryml/dryml_generator.rb
+++ b/dryml/lib/dryml/dryml_generator.rb
@@ -195,6 +195,7 @@ require 'fileutils'
           refl = model.reflections[collection]
           klass = refl.klass
           klass < ActiveRecord::Acts::List::InstanceMethods &&
+            klass.table_exists? &&
             klass.new.position_column == refl.options[:order].to_s
         end
       end
diff --git a/hobo/lib/hobo/model/view_hints.rb b/hobo/lib/hobo/model/view_hints.rb
index 030df6e..9ff4f27 100644
--- a/hobo/lib/hobo/model/view_hints.rb
+++ b/hobo/lib/hobo/model/view_hints.rb
@@ -73,6 +73,7 @@ module Hobo
           if arg.nil?
             @sortable ||= defined?(ActiveRecord::Acts::List::InstanceMethods) &&
                           model < ActiveRecord::Acts::List::InstanceMethods &&
+                          model.table_exists? &&
                           model.new.try.scope_condition == "1 = 1"
           else
             @sortable = arg
-- 
1.7.3.5

Reply via email to