Skip to content

Instantly share code, notes, and snippets.

@jpzwarte
Created January 9, 2011 19:07
Show Gist options
  • Save jpzwarte/771915 to your computer and use it in GitHub Desktop.
Save jpzwarte/771915 to your computer and use it in GitHub Desktop.
diff --git a/lib/inherited_resources/base_helpers.rb b/lib/inherited_resources/base_helpers.rb
index ccdf7ae..e94d875 100644
--- a/lib/inherited_resources/base_helpers.rb
+++ b/lib/inherited_resources/base_helpers.rb
@@ -73,6 +73,15 @@ module InheritedResources
#
def update_resource(object, attributes)
object.update_attributes(attributes)
+ attributes.keys.each do |key|
+ key.match(/^(?<association_name>\w+)_attributes$/)
+ if association_name
+ && resource_class.reflect_on_association(assocation_name).present?
+ && attributes["#{assocation_name}_attributes"]["_destroy"] == true
+ object.reload
+ break
+ end
+ end
end
# Handle the :destroy method for the resource. Overwrite it to call your
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment