# Ajax :update used when redirect\_to action

**URL:** <https://www.ruby-forum.com/t/ajax-update-used-when-redirect-to-action/84880>\
**Category:** Rails\
**Created:** [February 8, 2007, 11:40am UTC](https://www.ruby-forum.com/t/ajax-update-used-when-redirect-to-action/84880 "2007-02-08T11:40:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [February 8, 2007, 11:40am UTC](https://www.ruby-forum.com/t/ajax-update-used-when-redirect-to-action/84880/1 "2007-02-08T11:40:42Z")

</div>

This action is called via an Ajax request… with a parameter :update  
‘mypropForm’  
def modify\_prop  
@ proposal = Proposal.find\_by\_id(params[:id])

# modify the proposal attribute…

```
.....

```

# if saved then redirect to proposal list

```
redirect_to(:action => "list_ proposal", :id => current_user ) and

```

return if @ proposal.save

# if error : redisplay proposal with errors

```
render :update do |page|
  page.replace_html 'mypropForm', :partial => 'myprop_form'
end

```

end

when saved, the redirect is performed… but the llist\_ proposal action  
doesn’t render the full layout as it should… it just render the  
partial ! even if the redirect\_to request is not an xml\_http\_request  
…

why this :update parameter is still used anyway to get rid of it in the  
redirect ?

thanks to Ajaxian gurus

kad

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [February 8, 2007, 12:51pm UTC](https://www.ruby-forum.com/t/ajax-update-used-when-redirect-to-action/84880/2 "2007-02-08T12:51:05Z")

</div>

you really don’t want to mix your rendering like that. and there is no  
need to use :update =\> ‘mypropForm’ in the ajax call in your view, as  
you are doing a page.replace\_html.

you’re making an ajax request, so instead of redirec\_to, you should do

render :update do |page|  
if @proposal.save  
page.redirect\_to …  
else  
page.replace\_html ‘mypropForm’, :partial =\> ‘myprop\_form’  
end  
end
