Forum: Ruby on Rails App vs Plugin/Engine - raise error message

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Wes Hays (Guest)
on 2007-03-24 21:33
(Received via mailing list)
Hello All

I have some code that I was duplicating across applications so I made it
a plugin (engine actually). The engine works fine but the only problem
is when I raise an error in the before_destroy method in my model (the
model is not in the engine).

Based on the example code below; if I have this code in a controller
that is not in a engine I will get the following error:

"Fee type is in use"

Which is exactly what I want.  However, if I have that exact same code
in my engine I get the full path to the file that raised the error plus
the error message "Fee type is in use".

`before_destroy': Fee type is in use"

I cannot figure out how to only get the error message without the other
stuff (path and method) as this could be a possible security risk.

I have tried the different options for the raise method but with no

I am using Ruby 1.8.5 and Rails version 1.2.3.
The following sample code is what's in question.

*** Model ***


 has_many :ga_locations

def before_destroy
  raise 'Fee type is in use' if self.ga_locations.count > 0


*** Controller ***


rescue Exception => err
  flash[:error] = err.message



I am not sure if this is a rails or engines issue but I thought I would
try the rails list first.

Any help on this would be appreciated.


James "Wes" Hays
Great Basin Development
P.O.Box 3503, Reno, Nevada 89505
This topic is locked and can not be replied to.