I have a list of records on a notification panel, i've used the gem public activity to populate the panel with these notifications, when a user clicks on one instance i redirect the user to a custom URL that will give details on that notification,on this redirection, i change the read column of that notification in the activities table to true
def email_confirmed
# loads one specific activity/notification using the id from the url params
@notification = load_activities.find(params[:id])
# get the establishment,that is the trackable object,using activity id
# get the establishment using the 'trackable_id' field in the activities
# table
# Update the read column in the database on visit on the notification details
# view
@notification.update_columns(read: true)
@establishment_id = @notification.trackable_id
# use this instance of an establishment in the 'view all' action view
@establishment_details = Establishment.where(id:@establishment_id)
end
I have a AJAX script running that deleted the read notifications
setInterval(function(){
$.ajax({
url:'/notifications/remove_read_notifications',
type: "GET",
success: function(data){
console.log("in side delete");
}
});
},3000);
Now while im reading the notification table, i would like that if a user would refresh this page, it must not give an error that says the instance with "id" does not exist in the database, as there a way to circumvent this that will allow me to store that notification temporarily,help would be appreciated