{"issue":{"created_at":"2011-12-06T19:26:51Z","state":"closed","updated_at":"2011-12-08T01:14:40Z","user":{"gravatar_id":"c2dc9c02ce7a041285725a4fc9e5f6d2","id":26460,"url":"https://api.github.com/users/sobrinho","login":"sobrinho","avatar_url":"https://secure.gravatar.com/avatar/c2dc9c02ce7a041285725a4fc9e5f6d2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":7,"body":"Using ActiveRecord we can return false from any callback to stop the destroy but IR thinks it's was destroyed and show the success message.\r\n\r\nThe issue could be simplified by this:\r\n\r\n``` ruby\r\nclass SomeController < InheritedResources::Base\r\n  def destroy_resource(object)\r\n    false\r\n  end\r\nend\r\n```\r\n\r\nCurrently I'm using this to workaround the issue:\r\n\r\n``` ruby\r\ndef destroy(options={}, &block)\r\n  object = resource\r\n\r\n  if destroy_resource(object)\r\n    options[:location] ||= smart_collection_url\r\n  else\r\n    options[:location] ||= edit_resource_path\r\n    options[:alert]    ||= t(\"flash.actions.destroy.alert\", :resource_name => resource_class.model_name.human)\r\n  end\r\n\r\n  respond_with_dual_blocks(object, options, &block)\r\nend\r\n```","assignee":null,"id":2466225,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"number":181,"title":"Destroy do not show flash message when object.destroy returns false","html_url":"https://github.com/josevalim/inherited_resources/issues/181","closed_at":"2011-12-07T07:37:49Z","url":"https://api.github.com/repos/josevalim/inherited_resources/issues/181","milestone":null},"action":"created","comment":{"created_at":"2011-12-08T01:14:40Z","updated_at":"2011-12-08T01:14:40Z","user":{"gravatar_id":"77237b97a465ae5a293ad323b7296837","id":26328,"url":"https://api.github.com/users/carlosantoniodasilva","login":"carlosantoniodasilva","avatar_url":"https://secure.gravatar.com/avatar/77237b97a465ae5a293ad323b7296837?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Ok, it seems like we're having some problems with the way it works today, by requiring errors to be added to the model to consider a failure destroy scenario. The issue #185 was opened by @derekprior a few hours later relating the same problem.\r\n\r\nI don't actually remember why we decided to let it this way, whether there was some drawback or not. After discussing with @josevalim, we believe that there seems to be no real problem to change this to check for destroy return value, so if you or @derekprior want to try out a patch, it'd be welcome :)\r\n\r\nThanks.","id":3056423,"url":"https://api.github.com/repos/josevalim/inherited_resources/issues/comments/3056423"}}