Ciao,
sto modificando uno scaffold per spostare i nodi.
Quindi nella vista ho messo una select name=“move” con
Nel controller ho la funzione update dello scaffold(leggermente
modificata):
la tabella categories ha ovviamente i campi ‘position’ e ‘parent_id’.
def update
@category = Category.find(params[:id])
if params[:move]==1
@category.move_to_top
elsif params[:move]==1
@category.move_to_bottom
end
@category.reload
respond_to do |format|
if @category.update_attributes(params[:category])
flash[:notice] = ‘Category was successfully updated.’
format.html { redirect_to(@category) }
format.xml { head :ok }
else
format.html { render :action => “edit” }
format.xml { render :xml => @category.errors, :status =>
:unprocessable_entity }
end
end
end
Ma quando effettuo l’update il campo ‘position’ non cambia e il nodo
rimane fermo, dove sbaglio?
Saluti
Alberto