Created
September 30, 2010 18:31
-
-
Save amiel/605064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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 %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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