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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:43:39+00:00 2026-06-05T16:43:39+00:00

I was wondering in what order are callbacks and validations called when an ActiveRecord

  • 0

I was wondering in what order are callbacks and validations called when an ActiveRecord object is created.

Let’s say I have some custom validations & callbacks like the following:

validates :reference_code, :if => :reference_code, :on => :create
before_create :assign_reference

which one will run first? The callback needs to happen first or else the validation may fail.

  • 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-05T16:43:41+00:00Added an answer on June 5, 2026 at 4:43 pm

    The most-up-to-date version of this list for the latest version of Rails can be found in the ActiveRecord::Callbacks documentation. The lists for Rails 4, 3 & 2 are below.

    Rails 4

    The most up-to-date version of this list can be found in the Rails 4 Guides.

    Creating an object

    • before_validation
    • after_validation
    • before_save
    • around_save
    • before_create
    • around_create
    • after_create
    • after_save
    • after_commit/after_rollback

    Updating an object

    • before_validation
    • after_validation
    • before_save
    • around_save
    • before_update
    • around_update
    • after_update
    • after_save
    • after_commit/after_rollback

    Destroying an object

    • before_destroy
    • around_destroy
    • after_destroy
    • after_commit/after_rollback

    Rails 3

    The most up-to-date version of this list can be found in the Rails 3 Guides.

    Creating an object

    • before_validation
    • after_validation
    • before_save
    • around_save
    • before_create
    • around_create
    • after_create
    • after_save

    Updating an object

    • before_validation
    • after_validation
    • before_save
    • around_save
    • before_update
    • around_update
    • after_update
    • after_save

    Destroying an object

    • before_destroy
    • around_destroy
    • after_destroy

    Rails 2

    The most up-to-date version of this list can be found in the Rails 2.3 Guides

    Creating an object

    • before_validation
    • before_validation_on_create
    • after_validation
    • after_validation_on_create
    • before_save
    • before_create
    • INSERT operation
    • after_create
    • after_save

    Updating an object

    • before_validation
    • before_validation_on_update
    • after_validation
    • after_validation_on_update
    • before_save
    • before_update
    • UPDATE operation
    • after_update
    • after_save

    Destroying an object

    • before_destroy
    • DELETE operation
    • after_destroy

    Since you need to first validate the reference_code, the assign_reference method can be called in the after_validation callback or any callback appearing after it in the list I provided above.

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

Sidebar

Related Questions

I was wondering how exactly does TCP implement in-order delivery. lets say this is
I was wondering what the best approach in order to have a UISegmentedControl appears
I was wondering if there was some starting resource in order to understand and
I have an Array of Strings that are in order A-Z. I was wondering
In order to simplify some code, I'm wondering if it is possible to parameterize
I was wondering if anyone knows how to use script-fu in order to have
i was wondering, in order to get a good SEO you have to use
With mod_python I am wondering why I have to create a PythonHandler in order
I am wondering if node.js makes any guarantee on the order async calls start/complete.
I was wondering if it is possible to remember the order in which rows

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.