Michael Kahle wrote: >> Mark Reginald James wrote: >>> Michael Kahle wrote: >>> Ooo. Another thought. I noticed that you are doing a transaction >>> without using the "rescue" catch. If something else goes wrong, besides >>> validation, you will never know what happened! :) >> Unless you have a pre-save model callback preventing the save for >> a specific reason by returning false, that you wish to signal to >> the user, such exceptions are better handled by an app-wide catcher. > > I'm really not sure what a pre-save model callback is. This is rapidly > getting over my head! :)
If a model before_validation, after_validation, or before_save method or block returns false, a valid record won't be saved, but you only get an exception if the saving method ended with an exclamation mark. > Are you saying that anything caught by "rescue" is something that you > wouldn't want to pass back to the user? Is this because, let's say, in > the event of a database failure it would better to send this to a log > file or something similar? Is the idea behind what you are saying that > we should only be passing validation errors back to the user? While you can use rescue sections in individual actions to specially handle and inform users about action-specific errors, to prevent duplication it's usually best to have other exceptions handled by a single method in application.rb that informs both the user and the developer than an unexpected error has occurred. e.g. See the exception_notification plugin. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---