I have problem when trying to create a nested set. in my model I declared it
to acts_as_nested_set,
then in my controller i define two actions:
def list_node
@root = Distrib.find(1)
@list = @root.full_set
end
def add_node
@root = Distrib.find(params[:id])
@distribs = Distrib.new(params[:distribs])
@root.add_child(@distribs)
render :action => ''list_node''
end
list_node action works fine, i can get the list of the nested set. but when
i am trying to add a child (add_node action) it always failed with the
following error:
Couldn''t find Distrib without an ID
/app/controllers/distribs_controller.rb:64:in `add_node''
script/server:49
line 64 is where the add_node action call the add_child() method. then
i am trying to pass an ID to the action:
def add_node
@root = Distrib.find(params[:id])
@last_id <#@last_id> = Distrib.find_by_sql "select max(id) as
last_id from distribs"
@params[''distribs''][''id''
<#@params[''distribs''][''id''>]
@last_id[0].send("last_id").to_i + 1
@distribs = Distrib.new(params[:distribs])
@root.add_child(@distribs)
render_action :list_node
end
but still i got the error. am i missing something ?
Thanks.
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails