Skip to content

Commit

Permalink
integrate recommendations from rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbauer committed Mar 15, 2024
1 parent 7db4f2e commit dfab4cb
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions plugins/messages/app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ def create
ActiveRecord::Base.transaction do
@current_user.with_lock do
@message = @current_user.send_messages.new(params[:message])
if @message.save
DeliverMessageJob.perform_later(@message)
redirect_to messages_url, notice: I18n.t('messages.create.notice')
else
raise ActiveRecord::Rollback # Rollback the transaction if the save fails
end
raise ActiveRecord::Rollback unless @message.save

DeliverMessageJob.perform_later(@message)
redirect_to messages_url, notice: I18n.t('messages.create.notice')
end
end
rescue ActiveRecord::RecordInvalid => e
# Handle validation errors
render action: 'new'
rescue ActiveRecord::RecordInvalid
# Handle validation errors
render action: 'new'
end

# Shows a single message.
Expand Down

0 comments on commit dfab4cb

Please sign in to comment.