announcements_controller.rb 300 B

12345678910111213
  1. class AnnouncementsController < ApplicationController
  2. before_action :mark_as_read, if: :user_signed_in?
  3. def index
  4. @announcements = Announcement.order(published_at: :desc)
  5. end
  6. private
  7. def mark_as_read
  8. current_user.update(announcements_last_read_at: Time.zone.now)
  9. end
  10. end