ActiveRecord errors ... Best way to rescue a live web application?

Hi all,

I have some issues when a link is clicked twice quickly that deletes
an ActiveRecord row.

All I really want to do is set up some universal catch that will
redirect all application errors to index.

Best way?

Thanks!

Shawn

try this:
instead of ActiveRecord::Errors use ActiveRecord::ActiveRecordError,

class ApplicationController < ActionController::Base

  rescue_from ActiveRecord::ActiveRecordError, :with => :method_name

private

  def method_name
    redirect_to your_path
  end

end

in your ApplicationController, define:

def rescue_action(exception)
  super # optional
  # your code
end

slindsey3000 wrote:

Hi all,

I have some issues when a link is clicked twice quickly that deletes
an ActiveRecord row.

All I really want to do is set up some universal catch that will
redirect all application errors to index.

Best way?

Put a redirect tag in 404.html or 500.html, perhaps.

Thanks!

Shawn

Best,

You can overwrite method_missing.

HTH,
Bill

@ Bituin Bautista

Thank you works great.