Hi, my webapp has registered users and it has articles, blog posts,
For all these resources I’ve a polymorphic Comment model which is
id content commentable_id commentable_type user_id created_at updated_at 1 Frist comment 2 Article 1 .... 2 Second comment 3 Post 2 .....
So for each commentable resource, I’ve a comment form at the bottom of
the commentable resource for users to comment.
I want a checkbox, when checked while submitting the comment, the
users should receive a notification, be it in Inbox or email since we
already have it on user signup, when other new comments are added
I want to have some model like Notifications where I could store the
commentable_type, commentable_id and user_id (to whom the notification
should be sent if there is any new comment created with the matching
commentable and user?
How can I implement the association between Comment and Notification?
For the checking part if there is any one subscribe to the particular
commentable resource is create a CommentObserver with after_create
hook to initialize the search and send notifications if there is any
But I’m confused what the association, model, controller and views
would look like to accomplish this? Since the comment model is already
polymorphic, can I create the Notification model as polymorphic too??