Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9070327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:39:48+00:00 2026-06-16T17:39:48+00:00

This is simple enough. I’m trying to use mongoid’s ‘after_destroy’ callback to do some

  • 0

This is simple enough.

I’m trying to use mongoid’s ‘after_destroy’ callback to do some cleanup operations.

Eg

class Model
    include Mongoid::Document

    after_destroy do |model|
        #Do cleanup stuff
    end
end

There are 2 ways to remove an object from mongo. Delete and Destroy. Destroy runs the callback but Delete Doesn’t.

The model’s routes are declared like this

  resources :models

So my question is, when someone sends a request to models/delete does the destroy method get called or the delete method?

If the latter, then is there any way to run callbacks with the delete function in mongo.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:39:51+00:00Added an answer on June 16, 2026 at 5:39 pm

    The HTTP method :delete that gets created in resources :models has no direct bearing on the method used in the model. the HTTP delete calls this method:

    class ModelsController < ApplicationController
    
      def delete
        model = Model.find(params[:id])
        model.destroy
        redirect_to models_path, notice: "Model removed"
      end
    end
    

    You’re able to change “delete” to “destroy” in the controller to suit your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load text into a textview. This seems simple enough: box.text
I am trying to do this: Seems simple enough, but no matter what I
This should seem simple enough, but can't figure it out. I was porting a
this seems like a simple enough question but I can't seem to find a
I'm sure this question has a simple enough answer, but I can't seem to
This should be a simple answer. I'm just not knowledgeable enough in CSS to
This simple problem is kiling me. I posted something earlier about trying to clean
Trying to make this simple applet - the first part just creates a simple
This seems simple enough. Elmah logs the errors, I see the error in the
Very inexperienced with Flash, but I hope this is simple enough for someone to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.