From: Joshua Muheim Date: 2008-06-19T04:26:07+09:00 Subject: Rather validate values or use exceptions? Hi all I'm working on a little Rails application and have a general coding question. So far my looks like the following: --- music_artist_id = params[:booking_ticket_music_artist_id] if music_artist_id and MusicArtist.exists?(music_artist_id) @music_artist = MusicArtist.find(music_artist_id) page[:mini_profile].show.reload else page[:mini_profile].hide end --- On the first line I'm checking whether an optional parameter is given or not. This works OK, but I wonder whether it is "better code" doing the following? --- begin @music_artist = MusicArtist.find(params[:booking_ticket_music_artist_id]) page[:mini_profile].show.reload rescue RecordNotFound page[:mini_profile].hide end --- When looking at it, the second one looks cleaner to me, but what would you say? Maybe the first one is quite faster than the second one? Thanks for your opinion, Josh -- Posted via http://www.ruby-forum.com/.