diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 66adcc46b..d950fe1c8 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -147,16 +147,15 @@ class MemosController < ApplicationController ActiveRecord::Base.transaction do begin memo = Memo.find_by!(id: params[:parent_id]) - reply = Memo.new - reply.content = params[:content] - reply.author = current_user - reply.forum_id = memo.forum_id - reply.subject = memo.subject - reply.root_id = memo.root_id || memo.id - memo.children << reply - m = Memo.find_by!(id: reply.root_id) + @reply = Memo.new + @reply.content = params[:content] + @reply.author = current_user + @reply.forum_id = memo.forum_id + @reply.subject = memo.subject + @reply.root_id = memo.root_id || memo.id + memo.children << @reply + m = Memo.find_by!(id: @reply.root_id) m.increment!(:all_replies_count) - normal_status("回复成功") rescue Exception => e tip_exception("回复失败,原因:#{e}") raise ActiveRecord::Rollback diff --git a/app/views/memos/reply.json.jbuilder b/app/views/memos/reply.json.jbuilder new file mode 100644 index 000000000..c117d2d24 --- /dev/null +++ b/app/views/memos/reply.json.jbuilder @@ -0,0 +1,2 @@ +json.(@reply, :id, :subject, :content, :hidden, :forum_id, :author_id, :all_replies_count, :is_md, :parent_id, :root_id, + :reward, :sticky, :updated_at, :created_at, :viewed_count) \ No newline at end of file