From def8b823b23554bd4831065ef89fa38edb5efd84 Mon Sep 17 00:00:00 2001 From: Ryan Neufeld Date: Tue, 21 Jul 2009 16:10:58 -0500 Subject: [PATCH] Had to move over to a get request - not particularly happy with how often this has happened --- app/controllers/admin/contact_cart_controller.rb | 13 ++++++------- app/views/contact_carts/_contacts.html.haml | 5 +---- app/views/shared/_bulk_contact_actions.html.erb | 3 ++- config/routes.rb | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/controllers/admin/contact_cart_controller.rb b/app/controllers/admin/contact_cart_controller.rb index d8c2534..0c50217 100644 --- a/app/controllers/admin/contact_cart_controller.rb +++ b/app/controllers/admin/contact_cart_controller.rb @@ -29,13 +29,12 @@ def create redirect_to params[:return_to] and return end - def remove - if request.post? - @contact_cart = @session_user.active_contact_cart - @contact_cart.contacts.delete( Contact.find(params[:contact_to_remove_id])) - @contact_cart.save - redirect_to params[:return_to] and return - end + def remove_contact + debugger + @contact_cart = @session_user.active_contact_cart + @contact_cart.contacts.delete( Contact.find(params[:contact_to_remove_id])) + @contact_cart.save + redirect_to params[:return_to] and return end # DELETE /contact_carts/1 # DELETE /contact_carts/1.xml diff --git a/app/views/contact_carts/_contacts.html.haml b/app/views/contact_carts/_contacts.html.haml index 48c4d97..ee0f5a8 100644 --- a/app/views/contact_carts/_contacts.html.haml +++ b/app/views/contact_carts/_contacts.html.haml @@ -2,7 +2,4 @@ - cart.contacts.each do |contact| %li.contact_cart_listing = contact.name_for_display - - form_tag(contact_cart_remove_contact_path(cart), :class => 'contact-cart-remove-contact') do - = hidden_field_tag 'contact_to_remove_id', contact.id - = hidden_field_tag 'return_to', url_for(sanitized_url_params) - = submit_tag 'X', :class => 'contact-cart-remove-submit' + = link_to icon (:vcard_delete), contact_cart_remove_contact_path(cart, :contact_to_remove_id => contact.id, :return_to => url_for(sanitized_url_params) ) \ No newline at end of file diff --git a/app/views/shared/_bulk_contact_actions.html.erb b/app/views/shared/_bulk_contact_actions.html.erb index 0cd876a..ed1f99f 100644 --- a/app/views/shared/_bulk_contact_actions.html.erb +++ b/app/views/shared/_bulk_contact_actions.html.erb @@ -82,7 +82,8 @@ Due Date: <%= calendar_date_select_tag "follow_up", '', :time => true, :minute_i <%= submit_tag 'Add Selected Contacts to Cart' %>
<%- if !@session_user.active_contact_cart.nil? %> - <%= link_to 'Delete my Active Contact Cart', @session_user.active_contact_cart, :confirm => "Are you sure you want to delete your active contact cart?", :method => :delete, :controller => 'admin/contact_carts' %> + <%= link_to ' ' + icon(:cart_put) + " Save Active", 'do_it'%> + <%= link_to ' ' + icon(:cart_delete) + 'Delete Active', @session_user.active_contact_cart, :confirm => "Are you sure you want to delete your active contact cart?", :method => :delete, :controller => 'admin/contact_carts' %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index edb7751..d4ab6bf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ ActionController::Routing::Routes.draw do |map| map.resources :contact_carts, :path_prefix => '/admin' do |cart| - cart.remove_contact 'remove', :method => 'put', :controller => 'contact_carts', :action => 'remove' + cart.remove_contact 'remove_contact', :method => 'get', :controller => 'contact_carts', :action => 'remove_contact' end map.resources :freemailer_campaign_contacts, :path_prefix => '/admin'