Module: PrivateExtension::PrivateMessages::PrivateMessageExtensions::ClassMethods
- Defined in:
- lib/private_message_extensions.rb
Instance Method Summary collapse
-
#read_message(id, reader) ⇒ Object
Ensures the passed user is either the sender or the recipient then returns the message.
Instance Method Details
#read_message(id, reader) ⇒ Object
Ensures the passed user is either the sender or the recipient then returns the message. If the reader is the recipient and the message has yet not been read, it marks the read_at timestamp.
38 39 40 41 42 43 44 45 |
# File 'lib/private_message_extensions.rb', line 38 def (id, reader) = where("sender_id = ? OR recipient_id = ?", reader, reader).first if .read_at.nil? && reader == .recipient .read_at = Time.now .save! end end |