Skip to content

Commit 8d57005

Browse files
committed
Update registers_controller.rb
1 parent 52d7eb0 commit 8d57005

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

app/controllers/registers_controller.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,25 @@ def coauthors_commit
275275
@coauthor = User.find_by_email_or_username(@register.coauthor)
276276
if @coauthor.present?
277277
rc_par = { register: @register, user: @coauthor }
278-
success =
278+
rc =
279279
case params['register']['action']
280280
when 'unlink'
281281
RegisterCoauthor.find_by(rc_par).destroy
282282
when 'up'
283-
RegisterCoauthor.find_by(rc_par).move_up
283+
RegisterCoauthor.find_by(rc_par).tap(&:move_up)
284284
else
285285
rc_par.merge!(order: @register.register_coauthors.size + 1)
286286
RegisterCoauthor.new(rc_par).save
287287
end
288288

289-
if success
289+
if rc && !rc.errors.present?
290290
flash[:notice] = 'Successfully updated coauthors'
291291
redirect_back(fallback_location: @register)
292292
else
293293
flash.now[:alert] = 'Error updating coauthors'
294+
rc.errors.each do |field, err|
295+
@register.add_error(:coauthor, err)
296+
end
294297
coauthors
295298
render :coauthors
296299
end

0 commit comments

Comments
 (0)