Basically, I want to create a notification like Facebook and Stackoverflow. Specifically, in a Post-Comments system, when a post get commented, everyone involved (people who creates the post and who create comments, except the new commenter) gets a notification message that this post get commented. And the notification get dismissed when people have read it.
I have tried to use mailboxer gem to implement it, but saddly there is no example available using its related methods, including social_stream itself.
Is there other way to create the Notification System?
And when I try to create it from scratch I get several problems:
Model Notification
topic_id: integer
user_id: integer
checked: boolean #so we can tell whether the notification is read or not
- Dismissing the notication after being read by users
I think we just need to turn every notification messages' "checked" attribute to true after user visit the index of notification.(In the NotificationsController)
def index
@notifications=current_user.notication.all
@notification.each do |notification|
notification.checked = true
end
@notification.save!
end
2.Selecting users to notify(and exclude the user making new comment)
I just have no idea in wrting queries....
3.Creating notifications
I think this should be something like
#in CommentController
def create
#after creating comments, creat notifications
@users.each do |user|
Notification.create(topic_id:@topic, user_id: user.id)
end
end
But I think this is really ugly
There is no need to anwer the 3 problems above, Any simple solution to the Notification System is preferable , thanks....