Skip to content

Commit

Permalink
Had to move over to a get request - not particularly happy with how o…
Browse files Browse the repository at this point in the history
…ften this has happened
  • Loading branch information
Ryan Neufeld committed Jul 21, 2009
1 parent c375b3e commit def8b82
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
13 changes: 6 additions & 7 deletions app/controllers/admin/contact_cart_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions app/views/contact_carts/_contacts.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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) )
3 changes: 2 additions & 1 deletion app/views/shared/_bulk_contact_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ Due Date: <%= calendar_date_select_tag "follow_up", '', :time => true, :minute_i
<%= submit_tag 'Add Selected Contacts to Cart' %><br/>

<%- 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 %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit def8b82

Please sign in to comment.