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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:23:49+00:00 2026-06-12T22:23:49+00:00

If I do the following: @user.name = John @user.url = www.john.com @user.save If I

  • 0

If I do the following:

@user.name = "John"    
@user.url = "www.john.com"
@user.save

If I use after_save

@user.url = "www.johnseena.com"
@user.save

What will happen when I do this?

I believe it should save the value because of the ‘after_save’ callback.

  • 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-12T22:23:50+00:00Added an answer on June 12, 2026 at 10:23 pm

    In my opinion, if you call save function in a after_save callback, then it will trap into a recursion unless you put a guard at the beginning. like this

    class User < AR::Base
          after_save :change_url
    
          def change_url
              #Check some condition to skip saving
              url = "www.johnseena.com"
              save              #<======= this save will fire the after_save again
          end
    end
    

    However, apart from putting a guard, you can use update_column also

    def change_url
        update_column(:url, "www.johnseena.com")
    end
    

    In this case it will not fire after_save. However, it will fire after_update. So if you have any update operation on that call back then you are in recursion again 🙂

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

Sidebar

Related Questions

I have user document collection like this: User { id:001 name:John, age:30, friends:[userId1,userId2,userId3....] }
I have the following model: class User: name = models.CharField( max_length = 200 )
I've got the following tables: User Basic Data (unique) [userid] [name] [etc] User Collection
I have following code class User attr_accessor :name end u = User.new u.name =
I have in the directory /config/initializers/constants_data.rb following line: ADM = User.find_by_name('admin').id This is working
I have the following sql tables: Authors: Id Name 2 John Smith Books: Id
I am trying to use a software name Selenium (web rat) to simulate user
Following the instructions here: http://www.padrinorb.com/guides/padrino-mailer I have the delivery method added on the app.rb
I have the following user resource: class UserResource(ModelResource): class Meta: queryset = User.objects.all() resource_name
Consider the following tables: users and tweets user_id name tweet_id user_id tweet spam -----------------

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.