RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: sandersky
I added some extra logic to not add the delete members when destroy is not included. Supports both only and except route options.
# This module adds delete URL helpers to allow resource deletion
def resources(*args, &block)
add_delete_members = true
args.each do |arg|
add_delete_members = false if arg.is_a?(Hash) and (
(arg.has_key?(:only) and !arg[:only].include?(:destroy)) or
(arg.has_key?(:except) and arg[:except].include?(:destroy))
yield if block_given?
delete :delete, action: :destroy