레일에 알림을 만드는 방법을 보여주는 결정적인 기사를 찾을 수 없습니다. 모두 좋은 솔루션 인 것처럼 Mailboxer에 대해 이야기하는 것처럼 보이지만 Notify 메서드에 대한 한 단락 이외에는 매우 모호합니다.레일에 알림 시스템을 만드는 데 걸리는 시간
그래서 나는 Activity (Public Activity Gem)에 속한 알림 모델을 만든 다음 활동 모델에서 after_create 콜백을 사용하여 문제의 activity 객체에 대한 notify 메소드를 호출하는 notify 메소드를 호출 할 생각이다. . 주석 모달가 호출도 그래서
class Comment
include PublicActivity::Model
tracked
def notify
#Loop through all involved users of this modal instance and create a Notify record pointing to the public activity
end
end
class Activity < PublicActivity::Activity # (I presume I can override the gems Activity model in my App?)
after_create :notify
private
def notify
#Call the notify function from the model referenced in the activity, in this case, comment
end
end
으로
는 공개 활동은 코멘트가 통지 모델에 저장하는 방법을 통지 한 후 다시 호출을 추적간단하게 구성 할 모델을 통지
user_id, activity_id, read:boolean
참고 : 모든 것이 컨트롤러에서 처리되도록 최선을 다하고 있습니다. 모든 것이 모델에서 더 잘 처리 될 것이라고 생각합니다. 하지만 난 당신이 필요 필드가있는 알림 모델을 만들 필요가
감사