From 695383da7a46a3e4dfe7adc41e47536c7e20f112 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Wed, 7 May 2025 13:49:45 +0200 Subject: [PATCH] Don't fail when no cards This will prevent nil errors when parsing the command. Instead, the regular command validation will trigger and the error will be handled as expected. --- app/models/command/cards.rb | 2 +- app/models/command/parser/context.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/command/cards.rb b/app/models/command/cards.rb index 8ba9e4c74..d3e47792e 100644 --- a/app/models/command/cards.rb +++ b/app/models/command/cards.rb @@ -4,7 +4,7 @@ module Command::Cards included do store_accessor :data, :card_ids - validates_presence_of :card_ids + validates_presence_of :card_ids, :cards end def undoable? diff --git a/app/models/command/parser/context.rb b/app/models/command/parser/context.rb index 770477963..09591ce72 100644 --- a/app/models/command/parser/context.rb +++ b/app/models/command/parser/context.rb @@ -11,6 +11,8 @@ class Command::Parser::Context user.accessible_cards.where id: params[:id] elsif controller == "cards" && action == "index" filter.cards + else + Card.none end end