#coding=utf-8 module Trustie module At extend ActiveSupport::Concern module ClassMethods def act_as_at_message(content, send_id) self.send :define_method, :act_as_at_message_func do users = self[content].scan //m users && users.flatten.uniq.each do |uids| uids.split(",").each do |uid| self.at_messages << AtMessage.new(user_id: uid, sender_id: self[send_id]) end end end end end end end ActiveRecord::Base.send(:include, Trustie::At)