Hi!

I just started using hobo and find that acts_as_list doesn’t work as
expected.

Issue #1: It doesn’t work with the current acts_as_list gem (0.1.2) at
all without patching the hobo sources – see attached patch.

Next, I tried a 1-to-many relationship. The models and controllers are
straight-forward as in the acts_as_list example, just added the children
declaration to the TodoList model and the auto_actions_for to the
TodoItem controller.

> class TodoItem < ActiveRecord::Base
> 
>   hobo_model # Don't put anything above this
> 
>   fields do
>     name :string
>     timestamps
>   end
> 
>   belongs_to :todo_list
>   acts_as_list :scope => :todo_list
> 
>   # --- Permissions --- #
>   […]
> end

> class TodoList < ActiveRecord::Base
> 
>   hobo_model # Don't put anything above this
> 
>   fields do
>     timestamps
>   end
> 
>   has_many :todo_items, :order => 'position'
>   children :todo_items
> 
>   # --- Permissions --- #
>   […]
> end

> class TodoItemsController < ApplicationController
> 
>   hobo_model_controller
> 
>   auto_actions :all
> 
>   auto_actions_for :todo_list, [:new, :create, :index]
> 
> end

Issue #3: As soon as a model acts as a list, I would expect it not to be
created/edited alone, without the parent element it cannot live with. I
would expect it to vanish from the top navigation bar for this reason.
That’s just a thought, though.

Issue #4: When editing the list item, it should not be possible to edit
or view its list position as it breaks the acts_as_list property.

Issue #5: It would be great if one can specify auto_actions_for …,
[:destroy] for such a list item to be directly deleted. Has this ever
been considered?



Issue #6: Next, I tried acts_as_list for many-to-many relations, and it
breaks completely. Has anyone ever looked at that scenario?

– Matthias

-- 
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.

diff -ru hobo-1.3.0.pre25/lib/hobo/model.orig/view_hints.rb 
hobo-1.3.0.pre25/lib/hobo/model/view_hints.rb
--- hobo-1.3.0.pre25/lib/hobo/model.orig/view_hints.rb  2011-01-05 
11:01:36.352000034 +0100
+++ hobo-1.3.0.pre25/lib/hobo/model/view_hints.rb       2011-01-07 
20:20:03.006000459 +0100
@@ -43,8 +43,8 @@
 
       setter :paginate?,    proc { !sortable? }
 
-      setter :sortable?,    proc { 
defined?(ActiveRecord::Acts::List::InstanceMethods) &&
-                                   model < 
ActiveRecord::Acts::List::InstanceMethods &&
+      setter :sortable?,    proc { defined?(ActsAsList::InstanceMethods) &&
+                                   model < ActsAsList::InstanceMethods &&
                                    model.new.try.scope_condition == "1 = 1" }
 
       setter :inline_booleans, [] do |*args|
diff -ru hobo_fields-1.3.0.pre25/lib/hobo_fields.orig/model.rb 
hobo_fields-1.3.0.pre25/lib/hobo_fields/model.rb
--- hobo_fields-1.3.0.pre25/lib/hobo_fields.orig/model.rb       2011-01-05 
11:01:34.802000016 +0100
+++ hobo_fields-1.3.0.pre25/lib/hobo_fields/model.rb    2011-01-07 
20:13:36.477000342 +0100
@@ -217,7 +217,7 @@
     end
 
     class << self
-      alias_method_chain :acts_as_list,  :field_declaration if 
defined?(ActiveRecord::Acts::List)
+      alias_method_chain :acts_as_list,  :field_declaration if 
defined?(ActsAsList)
       alias_method_chain :attr_accessor, :rich_types
     end
 
diff -ru dryml-1.3.0.pre25/lib/dryml.orig/dryml_generator.rb 
dryml-1.3.0.pre25/lib/dryml/dryml_generator.rb
--- dryml-1.3.0.pre25/lib/dryml.orig/dryml_generator.rb 2011-01-05 
11:01:35.528000013 +0100
+++ dryml-1.3.0.pre25/lib/dryml/dryml_generator.rb      2011-01-07 
20:18:54.485000402 +0100
@@ -191,10 +191,10 @@
         # does not provide any metadata to reflect on, but if the :order
         # option is the same as the target classes position_column, that's a
         # pretty safe bet
-        if defined? ActiveRecord::Acts::List::InstanceMethods
+        if defined? ActsAsList::InstanceMethods
           refl = model.reflections[collection]
           klass = refl.klass
-          klass < ActiveRecord::Acts::List::InstanceMethods &&
+          klass < ActsAsList::InstanceMethods &&
             klass.new.position_column == refl.options[:order].to_s
         end
       end

Reply via email to