Skip to content

Instantly share code, notes, and snippets.

@amiel
Created September 30, 2010 18:31
Show Gist options
  • Save amiel/605064 to your computer and use it in GitHub Desktop.
Save amiel/605064 to your computer and use it in GitHub Desktop.
<%= highlight(t(:'.confirm', :resource => resource, :default => :'delete.confirm'), resource.to_s) %>
<%= semantic_form_for resource, :html => { :method => :delete } do |form| %>
<%= form.buttons do %>
<%= form.commit_button :delete %>
<% end %>
<% end %>
module AddDeleteToResourceRoutes
class Railtie < Rails::Railtie
initializer "add_delete_to_resource_routes.initialize" do |app|
ActionDispatch::Routing::Mapper::Resources.class_eval do
def resources_with_delete_action(*resources, &block)
resources_without_delete_action *resources do
yield if block_given?
member_scope do
get :delete
end
end
end
alias_method_chain :resources, :delete_action
end
end
end
end
See my blog post about this at http://amielmartin.tumblr.com/post/1216720481/delete-action-in-rails-3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment