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

in your ApplicationController, define:

def rescue_action(exception)
super # optional

your code

end

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
----- Original Message -----
From: “slindsey3000” [email protected]
To: “Ruby on Rails: Talk” [email protected]
Sent: Thursday, August 12, 2010 10:34 AM
Subject: [Rails] ActiveRecord errors … Best way to rescue a live web
application?

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,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

@ Bituin Bautista

Thank you works great.

On Aug 11, 7:22 pm, “Bituin Bautista” [email protected]

On Thu, Aug 12, 2010 at 9:24 AM, Marnen Laibow-Koser
[email protected] wrote:

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

You can overwrite method_missing.

HTH,
Bill

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs