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.
-- 
Posted via http://www.ruby-forum.com/.
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
http://handyrailstips.com
On Jul 14, 7:21 pm, Mickael Faivre-Macon <rails-mailing-l...@andreas-
s.net> wrote:> 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.
> --
> Posted viahttp://www.ruby-forum.com/.
forgot to add the .destroy() call there :S On Jul 14, 7:40 pm, Gavin <ga...-YMj/zd8x6QpKMzDMP321V2ksYUyLi9NM@public.gmane.org> wrote:> 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 > > http://handyrailstips.com > > On Jul 14, 7:21 pm, Mickael Faivre-Macon <rails-mailing-l...@andreas- > > s.net> wrote: > > 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. > > -- > > Posted viahttp://www.ruby-forum.com/. > >
Great Gavin, thanks ! Gavin Morrice 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-- Posted via http://www.ruby-forum.com/.