我在通知面板上有一个记录列表,我使用 gem public 活动来用这些通知填充面板,当用户单击一个实例时,我将用户重定向到一个自定义 URL,该 URL 将提供有关该通知的详细信息,在此重定向中,我将活动表中该通知的读取列更改为 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
我有一个 AJAX 脚本正在运行,它删除了读取通知
setInterval(function(){
$.ajax({
url:'/notifications/remove_read_notifications',
type: "GET",
success: function(data){
console.log("in side delete");
}
});
},3000);
现在,当我阅读通知表时,我希望如果用户刷新此页面,它不能给出一个错误,指出数据库中不存在具有“id”的实例,因为有一种方法可以规避这种情况允许我暂时存储该通知,将不胜感激