I have a Notifications table that a query using an ID provided by the url parameters hash.
Say I have the following URL : videos/11?notification=5
The 5 maps to a notification. But say a user change 5for 7and submits the URL. If a notification with ID 7 does not exist, Rails sends an error saying it could not find a notification with ID 7. I would like it to simply ignore the error and continue. I am making some tests after the find so nothing unwanted happens.
In your controller, you are likely using
Notification.find. This will throw an error if no record can be found with the given id. The finder methodNotification.find_by_idwill not throw an exception if no record can be found, and will instead returnnil.