# Getting the response body

**URL:** <https://www.ruby-forum.com/t/getting-the-response-body/172098>\
**Category:** Rails\
**Created:** [July 14, 2009, 8:21pm UTC](https://www.ruby-forum.com/t/getting-the-response-body/172098 "2009-07-14T20:21:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [July 14, 2009, 8:21pm UTC](https://www.ruby-forum.com/t/getting-the-response-body/172098/1 "2009-07-14T20:21:38Z")

</div>

Hi,

In my view I have

link\_to\_remote(image\_tag(“trashcan.gif”), :url=\>{:action=\>‘destroy’,  
:id=\>jobtype.id}, :confirm=\>I18n.t(:confirm\_action),  
:success=\>"$(‘el\_#{jobtype.id}’).fade()", :failure=\>“alert(‘HERE I WANT  
THE TEXT GENERATED BY THE CONTROLLER’)”)

And in the controller:  
def destroy  
id = params[:id]  
render(:text=\>“THIS TEXT”, :status=\>:forbidden) and return if  
Job.find(:all, :conditions=\>[“type\_id=?”,id]).size \> 0  
JobType.destroy(id)  
render(:nothing=\>true)  
end

How can I get the text rendered by the controller ?

response[‘body’] can not be used here.

Thanks,  
Mickael.

---

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [July 14, 2009, 8:41pm UTC](https://www.ruby-forum.com/t/getting-the-response-body/172098/2 "2009-07-14T20:41:11Z")

</div>

Hey,

Why not try:

def destroy  
id = params[:id]  
render :update do |page|  
page.alert( “THIS TEXT” ) if Job.find(:all, :conditions=\>  
[“type\_id=?”,id]).size \> 0  
end  
end

Gavin

> **[Ruby on Rails tips & Tutorials](https://handyrailstips.com/)**
>
> Ruby on Rails tips and tutorials

On Jul 14, 7:21 pm, Mickael Faivre-Macon \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [July 14, 2009, 8:42pm UTC](https://www.ruby-forum.com/t/getting-the-response-body/172098/3 "2009-07-14T20:42:22Z")

</div>

forgot to add the .destroy() call there :S

---

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [July 19, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/getting-the-response-body/172098/4 "2009-07-19T21:47:25Z")

</div>

Great Gavin, thanks !

Gavin M. wrote:

> Why not try:
> 
> def destroy  
> id = params[:id]  
> render :update do |page|  
> page.alert( “THIS TEXT” ) if Job.find(:all, :conditions=\>  
> [“type\_id=?”,id]).size \> 0  
> end  
> end
