closet_hangers#destroy now tied to hanger ID, not item
This commit is contained in:
parent
44156c5b21
commit
7d0edbf23c
3 changed files with 4 additions and 7 deletions
|
@ -1,11 +1,10 @@
|
||||||
class ClosetHangersController < ApplicationController
|
class ClosetHangersController < ApplicationController
|
||||||
before_filter :authorize_user!, :only => [:destroy, :create, :update, :update_quantities, :petpage]
|
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]
|
before_filter :find_user, :only => [:index, :petpage, :update_quantities]
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
raise ActiveRecord::RecordNotFound unless params[:closet_hanger]
|
@closet_hanger = current_user.closet_hangers.find params[:id]
|
||||||
@closet_hanger = current_user.closet_hangers.find_by_item_id_and_owned!(@item.id, owned)
|
|
||||||
@closet_hanger.destroy
|
@closet_hanger.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_after_destroy! }
|
format.html { redirect_after_destroy! }
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
= f.number_field :quantity, :min => 0, :required => true, :title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}"
|
= f.number_field :quantity, :min => 0, :required => true, :title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}"
|
||||||
= f.submit "Save"
|
= f.submit "Save"
|
||||||
- if show_controls
|
- 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
|
= return_to_field_tag
|
||||||
= hidden_field_tag 'closet_hanger[owned]', closet_hanger.owned
|
= hidden_field_tag 'closet_hanger[owned]', closet_hanger.owned
|
||||||
= submit_tag "Remove"
|
= submit_tag "Remove"
|
||||||
|
|
|
@ -52,7 +52,7 @@ OpenneoImpressItems::Application.routes.draw do |map|
|
||||||
|
|
||||||
resources :users, :path => 'user', :only => [:index, :update] do
|
resources :users, :path => 'user', :only => [:index, :update] do
|
||||||
resources :contributions, :only => [:index]
|
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
|
collection do
|
||||||
get :petpage
|
get :petpage
|
||||||
end
|
end
|
||||||
|
@ -65,8 +65,6 @@ OpenneoImpressItems::Application.routes.draw do |map|
|
||||||
put :update_quantities
|
put :update_quantities
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :closet_hanger, :only => [:update, :destroy]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue