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:
@@ -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
|
||||
|
||||
@@ -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}@")
|
||||
|
||||
Reference in New Issue
Block a user