diff --git a/app/controllers/commands_controller.rb b/app/controllers/commands_controller.rb index d1247a668..1f835408f 100644 --- a/app/controllers/commands_controller.rb +++ b/app/controllers/commands_controller.rb @@ -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 diff --git a/app/models/command/parser.rb b/app/models/command/parser.rb index 6b3f83bfc..dc20bd369 100644 --- a/app/models/command/parser.rb +++ b/app/models/command/parser.rb @@ -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