work around stale object error not being thrown

pull/8915/head
ulferts 4 years ago committed by Oliver Günther
parent 7a4826e6c9
commit 12b507171c
  1. 25
      modules/meeting/app/controllers/meeting_contents_controller.rb

@ -61,18 +61,17 @@ class MeetingContentsController < ApplicationController
def update
(render_403; return) unless @content.editable? # TODO: not tested!
@content.attributes = content_params
@content.author = User.current
@content.attributes = content_params.merge(author: User.current)
@content.attach_files(permitted_params.attachments.to_h)
if @content.save
flash[:notice] = I18n.t(:notice_successful_update)
redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting
if !@content.lock_version_changed?
if @content.save
flash[:notice] = I18n.t(:notice_successful_update)
redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting
end
else
render_conflict
end
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
flash.now[:error] = I18n.t(:notice_locking_conflict)
params[:tab] ||= 'minutes' if @meeting.agenda.present? && @meeting.agenda.locked?
render 'meetings/show'
end
def history
@ -137,6 +136,12 @@ class MeetingContentsController < ApplicationController
render_404
end
def render_conflict
flash.now[:error] = I18n.t(:notice_locking_conflict)
params[:tab] ||= 'minutes' if @meeting.agenda.present? && @meeting.agenda.locked?
render 'meetings/show'
end
def content_params
params.require(@content_type).permit(:text, :lock_version, :comment)
end

Loading…
Cancel
Save