tabletop-companion/app/models/dice_roll.rb

18 lines
429 B
Ruby

# frozen_string_literal: true
class DiceRoll < ApplicationRecord
belongs_to :rollable, polymorphic: true
belongs_to :table
validates :result, presence: true,
numericality: { only_integer: true }
after_create_commit do
broadcast_append_to table, target: "events"
end
def display_text
"#{rollable.character.name} rolled #{rollable.name}: <strong>#{result}</strong>".html_safe
end
end