From b48ee28e586fd75e84e33fabfcba70c05d32a606 Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 8 Sep 2009 20:06:44 +0200 Subject: lots of gui improvements for creating nodes --- app/controllers/nodes_controller.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'app/controllers/nodes_controller.rb') diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index f8b8058..a23354c 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -28,15 +28,17 @@ class NodesController < ApplicationController end def create - @node = Node.new( params[:node] ) - - parent = Node.find(params[:parent_id]) + parent = case params[:kind] + when "top_level" then Node.root + when "update" then Update.find_or_create_parent + when "generic" then Node.find(params[:parent_id]) + end - if parent and @node.save - @node.move_to_child_of parent + if parent + @node = parent.children.create(:slug => params[:title].parameterize.to_s) + @node.draft.update_attributes(:title => params[:title]) redirect_to(edit_node_path(@node)) else - @node.errors.add("Parent node") render :action => :new end end -- cgit v1.3