내 의견 모델에 적절한 멤버에게 전달되는 알림을 생성하는 콜백이 있는데, current_member가 자신의 주석 처리 가능한 객체에 댓글을 달고있는 경우 알림을 보내지 않도록하고 싶습니다. 내가 사용 해봤하지 않는 한이 같은 조건 :콜백에서 조건 사용하기 레일
after_create :create_notification, on: :create, unless: Proc.new { |commentable| commentable.member == current_member }
def create_notification
subject = "#{member.user_name}"
body = "wrote you a <b>Comment</b> <p><i>#{content}</i></p>"
commentable.member.notify(subject, body, self)
end
하지만이 오류를 얻을 : undefined local variable or method 'current_member' for #<Comment:0x746e008
어떻게 내가 원하는처럼이 일을 어떻게해야합니까?
올바른 방향으로 나를 가리켜 주셔서 감사합니다. 어쨌든 current_member를 호출 할 필요가 없었습니다. 단, 다음과 같은 경우는 예외입니다 : Proc.new {| comment | comment.member.id == comment.commentable.member.id}'대신에 – iamdhunt