diff --git a/app/controllers/closet_hangers_controller.rb b/app/controllers/closet_hangers_controller.rb index 13f844a0..01b3a3d3 100644 --- a/app/controllers/closet_hangers_controller.rb +++ b/app/controllers/closet_hangers_controller.rb @@ -1,11 +1,10 @@ class ClosetHangersController < ApplicationController before_filter :authorize_user!, :only => [:destroy, :create, :update, :update_quantities, :petpage] - before_filter :find_item, :only => [:destroy, :create, :update_quantities] + before_filter :find_item, :only => [:create, :update_quantities] before_filter :find_user, :only => [:index, :petpage, :update_quantities] def destroy - raise ActiveRecord::RecordNotFound unless params[:closet_hanger] - @closet_hanger = current_user.closet_hangers.find_by_item_id_and_owned!(@item.id, owned) + @closet_hanger = current_user.closet_hangers.find params[:id] @closet_hanger.destroy respond_to do |format| format.html { redirect_after_destroy! } diff --git a/app/views/closet_hangers/_closet_hanger.html.haml b/app/views/closet_hangers/_closet_hanger.html.haml index 33648290..9f5bee40 100644 --- a/app/views/closet_hangers/_closet_hanger.html.haml +++ b/app/views/closet_hangers/_closet_hanger.html.haml @@ -11,7 +11,7 @@ = f.number_field :quantity, :min => 0, :required => true, :title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}" = f.submit "Save" - if show_controls - = form_tag user_item_closet_hanger_path(current_user, closet_hanger.item), :method => :delete, :class => 'closet-hanger-destroy' do + = form_tag [current_user, closet_hanger], :method => :delete, :class => 'closet-hanger-destroy' do = return_to_field_tag = hidden_field_tag 'closet_hanger[owned]', closet_hanger.owned = submit_tag "Remove" diff --git a/config/routes.rb b/config/routes.rb index 9af5ccd2..23be9817 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,7 +52,7 @@ OpenneoImpressItems::Application.routes.draw do |map| resources :users, :path => 'user', :only => [:index, :update] do resources :contributions, :only => [:index] - resources :closet_hangers, :only => [:index, :update], :path => 'closet' do + resources :closet_hangers, :only => [:index, :update, :destroy], :path => 'closet' do collection do get :petpage end @@ -65,8 +65,6 @@ OpenneoImpressItems::Application.routes.draw do |map| put :update_quantities end end - - resource :closet_hanger, :only => [:update, :destroy] end end