AdamNYC
AdamNYC

Reputation: 20445

How to mark an email as read in Rails

I am working on a simple intra-site private messaging system, which looks similar to Facebook messages. I would like to have an email marked as read if user click on a button that leads to mailbox page, which shows multiple emails .

I am undecided about where to put this logic: in controller under messages_controller#show or in model using after_touch callback.

My question is: which solution is better and why?

Upvotes: 1

Views: 242

Answers (1)

GeekOnCoffee
GeekOnCoffee

Reputation: 1165

It sounds like you want to control when it gets marked as read, so I'd suggest doing it in messages_controller#show

This would simplify things such as having another interface for viewing messages (sent items?) that didn't mark them as read.

Upvotes: 2

Related Questions