I get the following error-message:
“Couldn’t find Activitycategory with ID=1”
How do I make RoR handle this error?
When the id is nog found he should return a string or 0 or whatever.
I’m guessing by using exceptions but I’m not very familiar with ruby
itself …
Help?
Steven.
Hello Steven,
I get the following error-message:
“Couldn’t find Activitycategory with ID=1”
How do I make RoR handle this error?
When the id is nog found he should return a string or 0 or whatever.
I’m guessing by using exceptions but I’m not very familiar with ruby
itself …
Yes, you have to catch the exception raised by the #find method :
begin
Activitycategory.find(1)
rescue RecordNotFound
handle the error
wish a flash[] message or whatever…
end
-- Jean-François.