before destroy is called before the destroy() method is called. you''re
not
calling destroy.
try this instead:
The controller :
def delete
Image.destroy(params[:id])
redirect_to :action => "list"
end
The model :
class Image < ActiveRecord::Base
set_table_name "publish_images"
belongs_to :article
before_destroy :on_destroy
private
def on_destroy
breakpoint # never hit this bkpoint
end
end
On 3/24/06, Christophe Gimenez <kandjidev@yahoo.fr>
wrote:>
> Hello, I''m trying to intercept delete call in my model but
> before_destroy callback is never called...
>
> Somebody knows why ?
>
> Thanks
>
> The controller :
>
> def delete
> Image.delete(params[:id])
> redirect_to :action => "list"
> end
>
> The model :
> class Image < ActiveRecord::Base
> set_table_name "publish_images"
> belongs_to :article
> before_destroy :on_destroy
>
> def delete
> end
>
> def on_destroy
> breakpoint # never hit this bkpoint
> end
> end
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/97d8c483/attachment.html