Skip to content
This repository has been archived by the owner on Jul 24, 2022. It is now read-only.

Commit

Permalink
Add default value for Announcement published_at
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Jun 13, 2021
1 parent 33f544e commit 2fde02c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/announcement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ class Announcement < ApplicationRecord
has_rich_text :description

validates :kind, :title, :description, :published_at, presence: true

after_initialize :set_defaults

def set_defaults
self.published_at ||= Time.current
end
end

0 comments on commit 2fde02c

Please sign in to comment.