module PrivateMessages::Models::PrivateMessage::ClassMethods
Public Instance Methods
around_user(user)
click to toggle source
# File lib/private_messages/models/private_message.rb, line 21 def around_user(user) klass_name.constantize.where("sender_id = ? or recipient_id = ?", user.id, user.id) end
is_private_message(options = {})
click to toggle source
# File lib/private_messages/models/private_message.rb, line 10 def is_private_message(options = {}) class_attribute :options self.options = options klass_name = options[:class_name] ||= "User" belongs_to :sender, :class_name => klass_name, :foreign_key => 'sender_id' belongs_to :recipient, :class_name => klass_name, :foreign_key => 'recipient_id' scope :unread, where("read_at is null") def around_user(user) klass_name.constantize.where("sender_id = ? or recipient_id = ?", user.id, user.id) end unless included_modules.include? InstanceMethods include InstanceMethods end end