From diego.algorta at gmail.com Wed Aug 1 11:47:12 2007 From: diego.algorta at gmail.com (Diego Algorta Casamayou) Date: Wed, 1 Aug 2007 12:47:12 -0300 Subject: [roar-users] view and fields for acts_as_tree or acts_as_nested_set Message-ID: <78d5ab170708010847q33c7cd70r6e1cd1f7565fcb9b@mail.gmail.com> Hi Wayne and others... I'm using BetterNestedSet [1] and have this model: [1] http://agilewebdevelopment.com/plugins/betternestedset class ProductCategory < ActiveRecord::Base acts_as_nested_set validates_presence_of :name validates_uniqueness_of :name, :scope => :parent_id after_save :update_proxy_parent def proxy_parent_id=(new_parent_id) @proxy_parent_id = new_parent_id end def proxy_parent_id @proxy_parent_id ||= self.parent_id end def proxy_parent_changed? proxy_parent_id != self.parent_id end protected def update_proxy_parent self.move_to_child_of(proxy_parent_id) if proxy_parent_changed? && !proxy_parent_id.blank? end end As you can see I had to add the "proxy_parent_id" attribute so I can change parents using roar. Heres the basic Controller with roar definition: class ProductCategoriesController < ApplicationController roar :prefix => 'admin' do collection :order => 'lft' do edit :name column :description delete end form do text_field :name select_field :proxy_parent_id, :choices => ProductCategory.to_select, :name => 'Parent category', :include_blank => true text_area :description end end end Problem is, I want a better way to represent the tree structure. Best thing would be to have full drag&drop functionality (like the :view => 'list') to manage ordering and reparenting of "Product Categories" (or any other tree/nested_set). But any suggestion on a good way to do this (even if it's very simpe and nothing to do with AJAX), would be appreciated. I've been trying customizing the 'list' view, but no REAL success. Anyone has implemented something like this? Thank you. Diego