# Making updates in after\_create callbacks

**URL:** <https://www.ruby-forum.com/t/making-updates-in-after-create-callbacks/123674>\
**Category:** Rails\
**Created:** [December 19, 2007, 5:52pm UTC](https://www.ruby-forum.com/t/making-updates-in-after-create-callbacks/123674 "2007-12-19T17:52:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [December 19, 2007, 5:52pm UTC](https://www.ruby-forum.com/t/making-updates-in-after-create-callbacks/123674/1 "2007-12-19T17:52:30Z")

</div>

Hi,

I’m seeing weird behavior on my live sites (can’t seem to duplicate in  
development). Using Ruby 1.8.6 on solaris with postgresql.

I often times have code that looks like:

class Order  
belongs\_to :user  
after\_create :make\_super\_user  
def make\_super\_user  
if user.orders.count \>= 50  
user.make\_super!  
end  
end  
end

class User  
has\_many :orders  
def make\_super!  
update\_attribute :super, true  
end  
end

That sort of thing, where there’s some check in an after\_create  
callback that does a count and then modifies another object. However,  
these callbacks don’t seem to be running correctly. Sometimes Users  
aren’t made super after 50 orders. Or, in this example:

class QuestionAnswer  
belongs\_to :question  
after\_create :rotate\_question  
def rotate\_question  
Question.rotate! if question.question\_answers.count \>= 100  
end  
end

Sometimes Question.rotate! is called if  
question.question\_answers.count is less than 100. It’s very weird.  
Anyone see anything like this?
