Instead of removing uncofirmed commands don't create them in the first place

This commit is contained in:
Jorge Manrubia
2025-05-07 14:47:15 +02:00
parent 6776e69ed8
commit 9c1185055e
2 changed files with 5 additions and 6 deletions
+3 -5
View File
@@ -6,12 +6,12 @@ class CommandsController < ApplicationController
def create
command = parse_command(params[:command])
if command&.valid?
if command.valid?
if confirmed?(command)
command.save!
result = command.execute
respond_with_execution_result(result)
else
command.destroy
render plain: command.title, status: :conflict
end
else
@@ -21,9 +21,7 @@ class CommandsController < ApplicationController
private
def parse_command(string)
Command::Parser.new(parsing_context).parse(string).tap do |command|
Current.user.commands << command
end
Command::Parser.new(parsing_context).parse(string)
end
def parsing_context
+2 -1
View File
@@ -9,7 +9,8 @@ class Command::Parser
def parse(string)
parse_command(string).tap do |command|
command&.line = string
command.user = user
command.line = string
end
end