Add save! method to ActiveModel models
This way we make it clear we expect records to be valid when we save them, just like we do with ActiveRecord models.
This commit is contained in:
@@ -16,6 +16,10 @@ class Verification::Letter
|
||||
letter_requested!
|
||||
end
|
||||
|
||||
def save!
|
||||
validate! && save
|
||||
end
|
||||
|
||||
def letter_requested!
|
||||
user.update(letter_requested_at: Time.current, letter_verification_code: generate_verification_code)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user