I added some extra logic to not add the delete members when destroy is not included. Supports both only and except route options.
ruby
# This module adds delete URL helpers to allow resource deletion# without using JavaScript to create destroy requestmoduleDeleteResourceRoutedefresources(*args, &block)
super(*args) do
add_delete_members = true
args.each do |arg|
add_delete_members = falseif arg.is_a?(Hash) and (
(arg.has_key?(:only) and !arg[:only].include?(:destroy)) or
(arg.has_key?(:except) and arg[:except].include?(:destroy))
)
endif add_delete_members
yieldif block_given?
member do
get :delete
delete :delete, action::destroyendendendendend
I added some extra logic to not add the delete members when destroy is not included. Supports both only and except route options.