Files
fizzy/app/models/command/cards.rb
T
Jorge Manrubia 695383da7a 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.
2025-05-07 13:49:45 +02:00

31 lines
467 B
Ruby

module Command::Cards
extend ActiveSupport::Concern
included do
store_accessor :data, :card_ids
validates_presence_of :card_ids, :cards
end
def undoable?
true
end
def needs_confirmation?
cards.many?
end
private
def cards
user.accessible_cards.where(id: card_ids)
end
def cards_description
if cards.one?
"card '#{cards.first.title}'"
else
"#{cards.count} cards"
end
end
end