Created
January 9, 2011 19:07
-
-
Save jpzwarte/771915 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
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