views:

88

answers:

1

Hi.

I have a simple question, and I am sure there is a standard answer to it; just can't find it. I have an ActiveResource user model in my rails app. It points to another rails app where my actual user entity lives. Everything in my app works fine while both apps are up. But when my back-end rails app is down; and I try to access activeresource model with save/find etc methods; it throws an error

NoMethodError: undefined method `closed?' for nil:NilClass

Before any create/save/find calls are made, is it possible for activeresource to know whether target rails app is running or now? Or should it be done as part of error handling? Any examples would be very helpful.

Cheers

+1  A: 

You can simply use Ruby Exceptions. For example:

begin 
  @resource = Resource.find :all
rescue Exception => e
  logger.error "Error caught " + e.to_s
end
Fadhli Rahim