Show private messages in foodsofts index pages (fixes #106)
This commit is contained in:
parent
f8148e7d30
commit
722bb474d1
7 changed files with 10 additions and 8 deletions
|
|
@ -9,9 +9,11 @@ class Message < ApplicationRecord
|
|||
|
||||
attr_accessor :send_method, :recipient_tokens, :order_id
|
||||
|
||||
scope :pub, -> { where(:private => false) }
|
||||
scope :threads, -> { where(:reply_to => nil) }
|
||||
scope :thread, -> (id) { where("id = ? OR reply_to = ?", id, id) }
|
||||
scope :readable_for, -> (user) {
|
||||
joins(:message_recipients).where('private = ? OR message_recipients.user_id = ?', false, user.try(&:id)).distinct
|
||||
}
|
||||
|
||||
validates_presence_of :message_recipients, :subject, :body
|
||||
validates_length_of :subject, :in => 1..255
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue