closet_hangers#destroy now tied to hanger ID, not item

This commit is contained in:
Emi Matchu 2011-10-31 17:13:36 -05:00
parent 44156c5b21
commit 7d0edbf23c
3 changed files with 4 additions and 7 deletions

View file

@ -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! }

View file

@ -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"

View file

@ -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