Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

redirect or render (See related posts)

Quick method to help your XHR requests degrade gracefully - via the caboo.se

def redirect_or_render( redirect_to_hash, render_page  )  
  if @request.xhr?
    render(render_page)
  else
    redirect_to(redirect_to_hash)
  end
end


Use like this:

redirect_or_render(  
  {:action=>'foo'},
  { :partial => 'monkey', :locals => { :obj = > 'x' } }
)

Comments on this post

RAVISH posts on Mar 04, 2006 at 09:26
Hi,
I am new javascipt lanuae can any body send javascript goodies

court3nay posts on Apr 08, 2006 at 09:45
damn it, i keep missing credit for my own code here!

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts