[The] RecordNotFound [exception is raised if] No record responded to the
find
method. Either the row with the given ID doesn't exist or the row didn't meet the additional restrictions. Some find calls [like thefind_by*
methods] do not raise this exception to signal nothing was found ..
Use find_by_id
(or find_by
) which will return nil
if the item is not found:
friendly.find_by_id params[:id]
friendly.find_by id: params[:id]