diff --git a/app/models/issue.rb b/app/models/issue.rb index 11daf670f..5ecb3e36f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -52,6 +52,7 @@ class Issue < ActiveRecord::Base # ForgeMessage虚拟关联(多态) has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy + has_many :at_messages, class_name: 'AtMessage', as: :at_message ,:dependent => :destroy acts_as_nested_set :scope => 'root_id', :dependent => :destroy acts_as_attachable :before_add => :attachment_added, :after_remove => :attachment_removed @@ -82,7 +83,7 @@ class Issue < ActiveRecord::Base attr_reader :current_journal # fq - after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message + after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message after_update :be_user_score after_destroy :down_user_score # after_create :be_user_score @@ -159,8 +160,9 @@ class Issue < ActiveRecord::Base # at 功能添加消息提醒 def act_as_at_message users = self.description.scan //m - ### xxx 在 xxx 中at了你 - + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id) + end end # 更新缺陷 diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb new file mode 100644 index 000000000..0b706c4ce --- /dev/null +++ b/app/views/users/_user_at_message.html.erb @@ -0,0 +1,21 @@ +<% if AtMessage === ma %> + +<% end %> \ No newline at end of file diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index f83e5617c..d690f7e43 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -17,6 +17,8 @@ <%# 系统消息 %> <%= render :partial => 'users/user_message_system', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_at_message', :locals => {:ma => ma} %> + <%# 课程消息 %> <%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %> diff --git a/db/schema.rb b/db/schema.rb index 17e613acb..2bf172198 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151209085942) do +ActiveRecord::Schema.define(:version => 20151216030610) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -66,6 +66,20 @@ ActiveRecord::Schema.define(:version => 20151209085942) do t.datetime "updated_at", :null => false end + create_table "at_messages", :force => true do |t| + t.integer "user_id" + t.integer "at_message_id" + t.string "at_message_type" + t.boolean "viewed" + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sender_id" + end + + add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" + create_table "attachments", :force => true do |t| t.integer "container_id" t.string "container_type", :limit => 30