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 8190871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:46:33+00:00 2026-06-07T03:46:33+00:00

I have the following after_save callbacks defined in my model. after_save :validate_image, :publish, :update_some_data,

  • 0

I have the following after_save callbacks defined in my model.

after_save :validate_image, :publish, :update_some_data, :send_notifications

Is it possible to skip rest of the after_save callbacks based on some condition in validate_image, so something like this –

def validate_image
  if image_not_valid
    # skip rest of the callbacks in the after_save chain
    destroy # destroy this record
  end
end

NOTE:- I am also destroying the record based on that condition and I have some “after_destroy” callbacks that need to be executed.

I am using Rails v3.2.6 with Mongoid v2.4.10, but I guess it wont make a difference if it was ActiveRecord.

  • 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-07T03:46:34+00:00Added an answer on June 7, 2026 at 3:46 am

    change your before_save definition like this

    after_save do
       validate_image
       unless image_not_valid
           publish 
           update_some_data 
           send_notifications
       end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function in my model after_save :update_status def update_status if quantity_received
I have the following models: class Application(models.Model): users = models.ManyToManyField(User, through='Permission') folder = models.ForeignKey(Folder)
I have a following model with mongoid rails3 class Address include Mongoid::Document embedded_in :person,
I have the following situation: class Professor(models.Model): default_address = models.OneToOneField('Address') class Address(models.Model): name =
I have the following model : class Model extends BaseModel { public function save($conn
I have the following 2 tables defined in migrations class CreateUsers < ActiveRecord::Migration def
I have the following setup: A model called Categories. These categories are managed using
Let us say we have the following scenario: class MyModel < ActiveRecord::Base after_save :throw_after_save
I have the following code: // After 8 seconds change the slide... var timeout
I'm trying to install memcached-1.2.8-repcached-2.2.1 I have the following error after running make :

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.