Hi, I have a class named Node that has another nodes acting like
sources and destinations.  We can build a graph using these nodes:

--------------------------------------------------
class Node < ActiveRecord::Base

  hobo_model # Don't put anything above this

  acts_as_nested_set :scope => :root_id

..............

  has_many :edges_as_source, :class_name => 'NodesEdges', :foreign_key
=> 'source_id', :dependent => :destroy, :order => :position
  has_many :edges_as_destination, :class_name =>
'NodesEdges', :foreign_key => 'destination_id'
  has_many :sources, :through => :edges_as_destination , :accessible
=> true
  has_many :destinations, :through => :edges_as_source ,  :order =>
'nodes_edges.position',:accessible => true

.......

end

-------------------

This is the nodes_edges class that allows us to connect the nodes:

-------------------

class NodesEdges < ActiveRecord::Base

  hobo_model # Don't put anything above this

  belongs_to :source, :class_name => 'Node', :creator => true
  belongs_to :destination, :class_name => 'Node'

  acts_as_list :scope => :source

  fields do
    timestamps
  end

....

end

-------------

NodesEdges has a position and it really works.  The destinations are
listed in the correct order.

BUT....

The problem is that *sortable-collection* is not working.

This is part of my application.dryml:
---------------------
<extend tag="show-page" for="SubSystem">
<old-show-page>
<field-list: fields="node_type, project, default_mode" param/>
<collection-section:>
....
  <h4 param="collection-heading">Destinations (for sorting reasons)</
h4>
  <sortable-collection:edges_as_source param/>
....
</old-show-page>
</extend>
-----------------------

The show page is showing perfectly, we can drag & drop, but it does
not alter the position value of the list.  I think it is invoking
nothing, cause if I add this to the NodesEdgesController:

  def reorder
    something to crash
  end

Nothing happens!!

I also have checked for activity in the Firebug, but nothing happened.

Just mention that SubSystem is a children class of Node:

-----------------------
class SubSystem < Node
  has_many :edges_as_source, :class_name => 'NodesEdges', :foreign_key
=> 'source_id', :dependent=>:destroy,:order => :position
  has_many :edges_as_destination, :class_name =>
'NodesEdges', :foreign_key => 'destination_id'
  has_many :sources, :through => :edges_as_destination , :accessible
=> true
  has_many :destinations, :through => :edges_as_source ,  :order =>
'nodes_edges.position', :accessible => true
...
end
---------------------

I have searched the hobo users group and internet and the cookbook and
found nothing:

* my position column is on the "list-item" class table.
* the acts_as_list is present and well scoped in the "list-item"
class.
* the has_many relationship is present in the "container" class and
has the :order => :position configured.
* the application.dryml has the <sortable-collection> tag.  I have
checked that the pages.dryml also generates the <sortable-collection>
tag.
* I have tested it without def reorder, with "def reorder hobo_reorder
end", and with "def reorder something to crash end", and no
differences.
* If I change manually the position column, it works.
* I have no null values in the position column.

Any idea of what is happening? Any new and interesting test to do?

 Thank you.

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

Reply via email to