Rescue Error in Module

Hi,

I am not sure why, but I get the following error when I try to catch a
specific exception:

uninitialized constant One::ActiveRecord::RecordNotFound

Here is some example code that I will use for simplification.

Why can’t I specify the RecordNotFound in the rescue?

I am calling the check_object method from the ApplicationController on a
before filter.

So Confused!!!

---------- CODE ----------

module One
module Two

def check_object

id = 12345

begin
  object = ObjectName.find(id)
rescue ActiveRecord::RecordNotFound => e
  logger.debug("#{e} : #{id}")
end

# more code would go here.

end

end
end

ActionController::Base.send :include, One::Two

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