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. 19
      modules/meeting/app/controllers/meeting_contents_controller.rb

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

Loading…
Cancel
Save