# frozen_string_literal: true class DiceRollsController < ApplicationController before_action :set_table def create rollable = dice_roll_params[:rollable_type].constantize.find(dice_roll_params[:rollable_id]) @table.dice_rolls.create!( rollable:, result: DiceRoller.new(rollable.roll_command, stat: rollable).roll, ) head :ok end private def set_table @table = Current.user.owned_tables.find(params[:table_id]) end def dice_roll_params params.require(:dice_roll).permit( :rollable_type, :rollable_id, ) end end