# Where did update\_without\_callbacks go?

**URL:** <https://www.ruby-forum.com/t/where-did-update-without-callbacks-go/131000>\
**Category:** Rails\
**Created:** [March 5, 2008, 3:02am UTC](https://www.ruby-forum.com/t/where-did-update-without-callbacks-go/131000 "2008-03-05T03:02:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dark-omen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@dark-omen](https://www.ruby-forum.com/u/dark-omen)\
**Post date:** [March 5, 2008, 3:02am UTC](https://www.ruby-forum.com/t/where-did-update-without-callbacks-go/131000/1 "2008-03-05T03:02:30Z")

</div>

I recently upgraded one of my apps to rails 2.0.2 and creating a  
certain object didn’t work. After some debugging, I discovered this  
exception:

undefined method `update\_without\_callbacks’ for #\<Journal:  
0x4fc7048\>

where Journal is my model and I have this callback in journal.rb:

def after\_save  
make\_journal\_name  
make\_inbound\_email  
self.update\_without\_callbacks  
end

(See \* below for more info)

Also, I thought while I was debugging that at some point I saw an  
exception that said I was trying to call a private method, but I can  
no longer reproduce that.

Anybody know what’s going on?

- Basically, what goes on here is that after I create or update a  
journal I need to create a name and inbound e-mail for the journal  
that include the journal\_id, so this has to happen in the after\_save  
so that the journal\_id is available. However, if I call self.save  
that creates an endless loop. See:  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/cc9cb64ca0923147/75432648e1aeee27?lnk=gst](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/cc9cb64ca0923147/75432648e1aeee27?lnk=gst)  
for more info.

---

<div class="post-metadata">

**Author:** ![dark-omen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@dark-omen](https://www.ruby-forum.com/u/dark-omen)\
**Post date:** [March 5, 2008, 7:40am UTC](https://www.ruby-forum.com/t/where-did-update-without-callbacks-go/131000/2 "2008-03-05T07:40:30Z")

</div>

On Mar 5, 12:01 pm, Scott [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> make_journal_name
> 
> ```
> 
> Anybody know what’s going on?
> 
> - Basically, what goes on here is that after I create or update a  
> journal I need to create a name and inbound e-mail for the journal  
> that include the journal\_id, so this has to happen in the after\_save  
> so that the journal\_id is available. However, if I call self.save  
> that creates an endless loop. See:[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/)…  
> for more info.

It’s hard to tell without knowing more of what the make\_journal\_name  
and make\_inbound\_email methods do. If these methods are updating  
attributes of the journal, you should probably move the  
self.update\_without\_callbacks to these methods as a  
self.update\_attribute(:attr, value) and call self.reload if necessary  
in your after\_save callback. Otherwise, you could try  
self.save\_without\_validation (or self.save\_with\_validation(false)),  
but I don’t know if these will skip the after\_save callback (I don’t  
think they will).

---

<div class="post-metadata">

**Author:** ![dark-omen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@dark-omen](https://www.ruby-forum.com/u/dark-omen)\
**Post date:** [March 5, 2008, 8:03am UTC](https://www.ruby-forum.com/t/where-did-update-without-callbacks-go/131000/3 "2008-03-05T08:03:57Z")

</div>

Unfortunately, calling self.update\_attribute creates an endless loop  
because #update\_attribute callsback after\_save.

Here’s a very simple example I setup where I simply want to append the  
ID of an object to it’s title after it’s created or updated:

class Movie \< ActiveRecord::Base  
def after\_save  
self.title = self.title + self.id.to\_s  
self.update\_without\_callbacks  
end  
end

and it throws this error:

NoMethodError in MoviesController#update  
private method `update\_without\_callbacks’ called for #\<Movie:  
0x38b1084\>

at /ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
attribute\_methods.rb:205:in `method\_missing’. That code calls “super”  
which is what throws the error…I presume because it’s calling the  
method on ActiveRecord::Base.

That being said, it seems that the access level of  
update\_without\_callbacks changed from 1.2.x to 2.x…is that a feature  
or a bug?

---

<div class="post-metadata">

**Author:** ![dark-omen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@dark-omen](https://www.ruby-forum.com/u/dark-omen)\
**Post date:** [March 5, 2008, 8:21am UTC](https://www.ruby-forum.com/t/where-did-update-without-callbacks-go/131000/4 "2008-03-05T08:21:32Z")

</div>

I’ve been trying to figure out how the access level has changed, but I  
can’t see it directly. I do see one meaningful change to callbacks.rb  
that occurred on 8/31/07: [http://dev.rubyonrails.org/changeset/7380](http://dev.rubyonrails.org/changeset/7380).  
I don’t really understand the change very well…anyone?
