From 4bb9085737cecf1b7ad6bfc17ab97a0790363f99 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 16:41:22 +0200 Subject: [PATCH] Hide implementation detail of reading --- app/controllers/notifications/readings_controller.rb | 2 +- app/models/notification.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/notifications/readings_controller.rb b/app/controllers/notifications/readings_controller.rb index 3c1c47c1a..5f593fa95 100644 --- a/app/controllers/notifications/readings_controller.rb +++ b/app/controllers/notifications/readings_controller.rb @@ -1,7 +1,7 @@ class Notifications::ReadingsController < ApplicationController def create @notification = Current.user.notifications.find(params[:id]) - @notification.update!(read_at: Time.current) + @notification.read end def create_all diff --git a/app/models/notification.rb b/app/models/notification.rb index d4ea87a95..617b2c0d4 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -15,6 +15,10 @@ class Notification < ApplicationRecord update!(read_at: Time.current) end + def read + update!(read_at: Time.current) + end + def read? read_at.present? end