课程留言无法删除

This commit is contained in:
sw 2015-08-21 17:00:17 +08:00
parent 3ef3a1d405
commit 0489b02e54
2 changed files with 17 additions and 15 deletions

View File

@ -70,20 +70,22 @@ class WordsController < ApplicationController
end end
def destroy def destroy
@journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) @journal_destroyed = JournalsForMessage.find params[:object_id]
if @journal_destroyed.jour_type == "Bid" if @journal_destroyed.destroy
@bid = Bid.find(@journal_destroyed.jour_id) if @journal_destroyed.jour_type == "Bid"
@jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count @bid = Bid.find(@journal_destroyed.jour_id)
elsif @journal_destroyed.jour_type == "Course" @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
@course = Course.find @journal_destroyed.jour_id elsif @journal_destroyed.jour_type == "Course"
@jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count @course = Course.find @journal_destroyed.jour_id
elsif @journal_destroyed.jour_type == "Principal" @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
@user = User.find(@journal_destroyed.jour_id) elsif @journal_destroyed.jour_type == "Principal"
@jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count @user = User.find(@journal_destroyed.jour_id)
@is_user = true @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
end @is_user = true
respond_to do |format| end
format.js respond_to do |format|
format.js
end
end end
end end

View File

@ -60,7 +60,7 @@ class JournalsForMessage < ActiveRecord::Base
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# 消息关联 # 消息关联
has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy
has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:user_feeback_message, :dependent => :destroy has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy
validates :notes, presence: true, if: :is_homework_jour? validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message