Only one invocation of this, not carrying the worth of its indirection

Generally I am wary of including global state checks in the belly of
models. It is one thing to do it as a default parameter, but I think it
is too far to do it inside an actual method.
This commit is contained in:
David Heinemeier Hansson
2025-04-05 12:40:08 +02:00
parent d237885bd4
commit 8ff017fc5b
2 changed files with 1 additions and 5 deletions
+1 -1
View File
@@ -38,6 +38,6 @@ class CommentsController < ApplicationController
end
def require_own_comment
head :forbidden unless @comment.creator.current?
head :forbidden unless Current.user == @comment.creator
end
end
-4
View File
@@ -32,10 +32,6 @@ class User < ApplicationRecord
end
end
def current?
Current.user == self
end
private
def deactived_email_address
email_address.sub(/@/, "-deactivated-#{SecureRandom.uuid}@")