when delete co-author relation, the co-author will be reset nil
This commit is contained in:
parent
7342fe0e24
commit
4ebbd7cb5a
|
@ -27,6 +27,7 @@ class Desktop::CoAuthorRelationsController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
@co_author_relation = CoAuthorRelation.find(params[:id])
|
@co_author_relation = CoAuthorRelation.find(params[:id])
|
||||||
@co_author_relation.destroy
|
@co_author_relation.destroy
|
||||||
|
#reset_co_author_relation @co_author_relation
|
||||||
|
|
||||||
render :json => {success: true, msg: "deleted successfully!"}
|
render :json => {success: true, msg: "deleted successfully!"}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
module Desktop::CoAuthorRelationsHelper
|
module Desktop::CoAuthorRelationsHelper
|
||||||
|
def reset_co_author_relation relation
|
||||||
|
co_author = CoAuthor.where(co_author_relations_id: relation)
|
||||||
|
co_author.map do |c|
|
||||||
|
co_author.update_attributes(co_author_relations_id: nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ FactoryGirl.define do
|
||||||
{ zh_tw: "#{name_tw[n]}",
|
{ zh_tw: "#{name_tw[n]}",
|
||||||
en: "#{name_en[n]}" }
|
en: "#{name_en[n]}" }
|
||||||
end
|
end
|
||||||
f.sequence(:type) do |n| "#{type[n%5]}" end
|
f.sequence(:co_author_relations_id) do |n| "#{CoAuthorRelation.all[n%type.size].id}" end
|
||||||
f.sequence(:email) do |n| "#{email[n]}" end
|
f.sequence(:email) do |n| "#{email[n]}" end
|
||||||
f.name_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account
|
f.name_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue