File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments