# Ajax Updater mystery

**URL:** <https://www.ruby-forum.com/t/ajax-updater-mystery/103113>\
**Category:** Rails\
**Created:** [May 1, 2007, 11:27pm UTC](https://www.ruby-forum.com/t/ajax-updater-mystery/103113 "2007-05-01T23:27:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/3d9bf3/32.png) [@Kenneth\_D](https://www.ruby-forum.com/u/Kenneth_D)\
**Post date:** [May 1, 2007, 11:27pm UTC](https://www.ruby-forum.com/t/ajax-updater-mystery/103113/1 "2007-05-01T23:27:01Z")

</div>

I have a form which contains the following updater:

When I use this form in a ‘new’ action, it works as expected. However,  
When I try it with an 'edit/ action, it fails to call  
updtrecipients,  
and instead calls edit, which renders the whole page into  
div\_recipients.  
I have noticed in the logs that params contains :id=\>‘updtrecipients’  
when this happens. Anyone know what’s going on? For now I have just  
added  
if request.xhr?  
updtrecipients and return true  
end  
to the top of my edit action, which works, but if anyone has a solution  
that is less ugly, I’d like to know what it is.

Thanks much

Ken

–

I use the words you taught me. If they don’t mean anything any more,  
teach me others. Or let me be silent.  
Samuel Beckett (Clov, Endgame)

---

<div class="post-metadata">

**Author:** ![Kenneth\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/3d9bf3/32.png) [@Kenneth\_D](https://www.ruby-forum.com/u/Kenneth_D)\
**Post date:** [May 2, 2007, 12:29am UTC](https://www.ruby-forum.com/t/ajax-updater-mystery/103113/2 "2007-05-02T00:29:11Z")

</div>

Hello Kenneth,

2007/5/1, Kenneth D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> onClick="new Ajax.Updater('div_recipients',
> 'updtrecipients',
> 
> ```
> 
> {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)}  
> ); return false;"\>

Your problem is the URL of the Updater. You’re telling it to POST  
relative to the current URL.

If you have /contacts/new, you’ll get /contacts/updtrecipients, and if  
you have /contacts/edit/13, you’ll get /contacts/edit/updtrecipients.

You’re much better off using absolute URLs, or using named routes  
(which give you absolute URLs always).

## Hope that helps !

François Beausoleil  
[http://blog.teksol.info/](http://blog.teksol.info/)  
[http://piston.rubyforge.org/](http://piston.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![Kenneth\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/3d9bf3/32.png) [@Kenneth\_D](https://www.ruby-forum.com/u/Kenneth_D)\
**Post date:** [May 2, 2007, 2:56pm UTC](https://www.ruby-forum.com/t/ajax-updater-mystery/103113/3 "2007-05-02T14:56:30Z")

</div>

Quoth Fran??ois Beausoleil (removed\_email\_address@domain.invalid):

> If you have /contacts/new, you’ll get /contacts/updtrecipients, and if  
> you have /contacts/edit/13, you’ll get /contacts/edit/updtrecipients.
> 
> You’re much better off using absolute URLs, or using named routes  
> (which give you absolute URLs always).
> 
> Hope that helps !

That seems to have done the trick. Thanks.

## Ken

I use the words you taught me. If they don’t mean anything any more,  
teach me others. Or let me be silent.  
Samuel Beckett (Clov, Endgame)
