From 26c4e9cffcacd906d21a201f74741753e24c0333 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Thu, 18 Oct 2012 09:33:16 -0400 Subject: [PATCH] fixed ability to edit topics --- app/controllers/items_controller.rb | 106 +--------------------------- 1 file changed, 1 insertion(+), 105 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index d26bd06b..ba69d8a9 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -55,36 +55,8 @@ class ItemsController < ApplicationController # GET /items/:id/edit def edit @item = Item.find_by_id(params[:id]) - - @ingroups = @item.groups - if @ingroups.count > 0 - @outgroups = Group.find(:all, :conditions => ['id not in (?)', @ingroups.map(&:id)]) - else - @outgroups = Group.all - end - - @inpeople = @item.people - if @inpeople.count > 0 - @outpeople = Person.find(:all, :conditions => ['id not in (?)', @inpeople.map(&:id)]) - else - @outpeople = Person.all - end - - @initems1 = @item.parent_items - if @initems1.count > 0 - @outitems1 = Item.find(:all, :conditions => ['id not in (?) AND id != ?', @initems1.map(&:id), @item.id]) - else - @outitems1 = Item.find(:all, :conditions => ['id != ?', @item.id]) - end - - @initems2 = @item.child_items - if @initems2.count > 0 - @outitems2 = Item.find(:all, :conditions => ['id not in (?) AND id != ?', @initems2.map(&:id), @item.id]) - else - @outitems2 = Item.find(:all, :conditions => ['id != ?', @item.id]) - end - respond_with(@item, @initems1, @outitems1, @initems2, @outitems2, @ingroups, @outgroups, @inpeople, @outpeople) + respond_with(@item) end # PUT /actions/:id @@ -100,82 +72,6 @@ class ItemsController < ApplicationController @item.save end - if params[:ingroups] - @ingroups = params[:ingroups] - @ingroups.each do |g| - @connection = Groupitem.where("group_id = ? AND item_id = ?", g, @item.id).first - @connection.delete - end - end - - if params[:outgroups] - @outgroups = params[:outgroups] - @outgroups.each do |g| - belongs = Groupitem.new - belongs.group_id = g - belongs.item_id = @item.id - belongs.save! - end - end - - if params[:inpeople] - @inpeople = params[:inpeople] - @inpeople.each do |g| - @connection = Personitem.where("person_id = ? AND item_id = ?", g, @item.id).first - @connection.delete - end - end - - if params[:outpeople] - @outpeople = params[:outpeople] - @outpeople.each do |g| - belongs = Personitem.new - belongs.person_id = g - belongs.item_id = @item.id - belongs.save! - end - end - - #remove the selected parent items - if params[:initems1] - @initems1 = params[:initems1] - @initems1.each do |g| - @connection = Itemitem.where("parent_item_id = ? AND item_id = ?", g, @item.id).first - @connection.delete - end - end - - #remove the selected parent items - if params[:outitems1] - @outitems1 = params[:outitems1] - @outitems1.each do |g| - belongs = Itemitem.new - belongs.parent_item_id = g - belongs.item_id = @item.id - belongs.save! - end - end - - #remove the selected children items - if params[:initems2] - @initems2 = params[:initems2] - @initems2.each do |g| - @connection = Itemitem.where("parent_item_id = ? AND item_id = ?", @item.id, g).first - @connection.delete - end - end - - #add the selected children items - if params[:outitems2] - @outitems2 = params[:outitems2] - @outitems2.each do |g| - belongs = Itemitem.new - belongs.parent_item_id = @item.id - belongs.item_id = g - belongs.save! - end - end - respond_with(@user, location: item_url(@item)) do |format| end