From 9b4d055b649ad24ad1482f72d138aa73da1e4bd7 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 9 Aug 2009 11:57:44 +0200 Subject: refactored the way new menu items are created. went back to rest and added the js ajax search to fill out the form for you. much cleaner, unobtrusive approach. --- app/controllers/menu_items_controller.rb | 15 +++++--------- app/views/menu_items/index.html.erb | 18 ++++++----------- app/views/menu_items/new.html.erb | 34 ++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 24 deletions(-) (limited to 'app') diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb index d6f0252..0ba56c3 100644 --- a/app/controllers/menu_items_controller.rb +++ b/app/controllers/menu_items_controller.rb @@ -10,20 +10,15 @@ class MenuItemsController < ApplicationController end def new + @menu_item = MenuItem.new params[:menu_item] end def create - respond_to do |format| - format.html {} - - format.js do - MenuItem.create params[:menu_item] - end - - + if MenuItem.create( params[:menu_item] ) + redirect_to menu_items_path + else + render :new end - - end def edit diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb index d2ff10e..db4a771 100644 --- a/app/views/menu_items/index.html.erb +++ b/app/views/menu_items/index.html.erb @@ -1,18 +1,12 @@ +<% content_for :subnavigation do %> + <%= link_to "new", new_menu_item_path %> +<% end %> + +

Menu Items

- - \ No newline at end of file + \ No newline at end of file diff --git a/app/views/menu_items/new.html.erb b/app/views/menu_items/new.html.erb index e3f800e..64b9abb 100644 --- a/app/views/menu_items/new.html.erb +++ b/app/views/menu_items/new.html.erb @@ -1,2 +1,32 @@ -

MenuItems#new

-

Find me in app/views/menu_items/new.html.erb

+

Add Menu Item

+ +<% form_for @menu_item do |f| %> + + + + + + + + + + + + + + + + + + + + + + +
Search + <%= text_field_tag :menu_search_term %> +
+ +
+
Node Id<%= f.text_field :node_id %>
Path<%= f.text_field :path %>
Title<%= f.text_field :title %>
<%= f.submit 'Create' %>
+<% end %> \ No newline at end of file -- cgit v1.3