Derm - On 30-Mar-09, at 12:11 PM, derm_w wrote: > > > > On Mar 29, 1:59 pm, derm_w <[email protected]> wrote: >> Hi all. >> >> I'm new to rails and am learning my way by putting together a simple >> app. > > > Many thanks Wouter for your reply. > > I've now got this:- > > def show > @album = Album.find(params[:id]) > unless @album then > render(:action => 'record_not_found') > end > render(:action => 'show_album') > end > > However I'm still getting "couldn't find album with ID=100" (or any > other number that doesn't exist) > > I wonder what's amiss? > > Dermot.
Model.find(id) intentionally returns an exception when the row isn't found. you can either trap the exception (rescue), or do a Model.find_by_id(id) which won't fire the exception. Jodi --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---

