5 ms·
I believe if you do Post.find on a nonexistent id, a ActiveRecord::RecordNotFound exception is thrown, but this doesn't happen with the dynamically generated fi
by ClifReeder 14y ago
I believe if you do Post.find on a nonexistent id, a ActiveRecord::RecordNotFound exception is thrown, but this doesn't happen with the dynamically generated finders like find_by_id. Given this difference, it's possible you want to handle a missing record in a more graceful, non exception catching matter.
- dasil003 14y agoPersonally I would do Post.where(id: params[:id]).first since I tend not to like dynamic finders anyway.