Problem with RecordNotFound without numeric id

Hi all,

I have a problem handling errors for RecordNotFound (Page 86 of Agile
Book), I want to redirect bad items id to “list” with a flash “Invalid
Item”, but this works only with numeric id, if I use some like
“wibble” the result is an empty list of items.

This is in my item_controller:

def show
@item = Item.find(params[:id])
redirect_to :action => ‘list’
flash[:notice] = ‘Invalid Item’

@item = Item.find(params[:id].to_i)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs