Rescue_from for javascript requests Rescue_from for javascript requests ajax ajax

Rescue_from for javascript requests


Just reraise the exception.

def show_js_errors exception  if request.format == :js    flash[:error] = 'some error occured'    render :update do |page|      page.redirect_to({:controller => '/home', :action => :index})    end  else    raise # <<  endend

http://simonecarletti.com/blog/2009/11/re-raise-a-ruby-exception-in-a-rails-rescue_from-statement/ concurs:

rescue_from ActiveRecord::StatementInvalid do |exception|  if exception.message =~ /invalid byte sequence for encoding/    rescue_invalid_encoding(exception)  else    raise  endend

[...]The exception is correctly rethrown but it isn't catched [sic] by the standard Rails rescue mechanism and the standard exception page is not rendered.