diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 392807479..61d15de55 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -38,6 +38,7 @@ class Shixun < ApplicationRecord belongs_to :user # 实训服务配置 has_many :shixun_service_configs, :dependent => :destroy + has_many :tidings, as: :container, dependent: :destroy scope :search_by_name, ->(keyword) { where("name like ? or description like ? ", "%#{keyword}%", "%#{keyword}%") } @@ -248,7 +249,7 @@ class Shixun < ApplicationRecord private def send_tiding - self.tidings << Tiding.new(:user_id => self.user_id, :trigger_user_id => self.user_id, :belong_container_id => self.id, :belong_container_type =>'Shixun', :tiding_type => "System", :viewed => 0) + self.tidings << Tiding.new(:user_id => user_id, :trigger_user_id => 1, :belong_container_id => id, :belong_container_type =>'Shixun', :tiding_type => "System", :viewed => 0) end end