新建论坛或者回复,如果传图了,要更新资源的owner

dev_repository_hjq
lizanle 10 years ago
parent b95f479c17
commit 5f203ec8c0

@ -1,7 +1,7 @@
# added by fq
class ForumsController < ApplicationController
layout "users_base"
include ApplicationHelper
# GET /forums
# GET /forums.json
before_filter :find_forum_if_available
@ -63,6 +63,9 @@ class ForumsController < ApplicationController
respond_to do |format|
if @memo.save
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@memo.id,1
#end
format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else
@ -163,6 +166,13 @@ class ForumsController < ApplicationController
@forum = Forum.new(params[:forum])
@forum.creator_id = User.current.id
if @forum.save
# Time 2015-03-24 17:07:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 2 对应的是 forum
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@forum.id,2
#end
respond_to do |format|
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }

@ -59,6 +59,20 @@ class MemosController < ApplicationController
@memo.content = @quote + @memo.content
respond_to do |format|
if @memo.save
# Time 2015-03-24 14:47:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 1 对应的是 memo
if !params[:asset_id].nil?
ids = params[:asset_id].split(',')
ids.each do |id|
asset = Kindeditor::Asset.find(id.to_i)
asset.owner_id = @memo.id
asset.owner_type = 1
asset.save
end
end
#end
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else

Loading…
Cancel
Save