diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb
new file mode 100644
index 0000000..174ebf2
--- /dev/null
+++ b/app/controllers/events_controller.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class EventsController < ApplicationController
+ layout "table"
+
+ before_action :set_table
+
+ def index
+ @characters = Current.user.characters.where(table: @table)
+ @events = @table.dice_rolls.order(:created_at)
+ end
+
+ private
+
+ def set_table
+ @table = Current.user.tables.find(params[:table_id])
+ end
+end
diff --git a/app/models/dice_roll.rb b/app/models/dice_roll.rb
index 8cd5d7c..d4b4952 100644
--- a/app/models/dice_roll.rb
+++ b/app/models/dice_roll.rb
@@ -6,4 +6,8 @@ class DiceRoll < ApplicationRecord
validates :result, presence: true,
numericality: { only_integer: true }
+
+ def display_text
+ "#{rollable.character.name} rolled #{rollable.name}: #{result}".html_safe
+ end
end
diff --git a/app/models/stat.rb b/app/models/stat.rb
index 0ac5796..c2e088b 100644
--- a/app/models/stat.rb
+++ b/app/models/stat.rb
@@ -4,6 +4,7 @@ class Stat < ApplicationRecord
include Sluggable
belongs_to :character_sheet_section
+ has_one :character, through: :character_sheet_section
has_many :dice_rolls, as: :rollable, dependent: :destroy
validates :name, presence: true,
diff --git a/app/views/dice_rolls/_dice_roll.html.erb b/app/views/dice_rolls/_dice_roll.html.erb
new file mode 100644
index 0000000..fcdf18a
--- /dev/null
+++ b/app/views/dice_rolls/_dice_roll.html.erb
@@ -0,0 +1,3 @@
+
+ <%= dice_roll.display_text %>
+
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb
new file mode 100644
index 0000000..458de76
--- /dev/null
+++ b/app/views/events/index.html.erb
@@ -0,0 +1,5 @@
+<% content_for :title, @table.name %>
+
+
+ <%= render @events %>
+
diff --git a/app/views/layouts/table.html.erb b/app/views/layouts/table.html.erb
index bdba9df..9d3d694 100644
--- a/app/views/layouts/table.html.erb
+++ b/app/views/layouts/table.html.erb
@@ -6,6 +6,7 @@
<% @characters.each do |character| %>
<%= link_to character.name, table_character_path(@table, character) %>
<% end %>
+ <%= link_to t(".events"), table_events_path(@table) %>
<% end %>
diff --git a/config/brakeman.ignore b/config/brakeman.ignore
index cc888d9..2a27796 100644
--- a/config/brakeman.ignore
+++ b/config/brakeman.ignore
@@ -7,7 +7,7 @@
"check_name": "Render",
"message": "Render path contains parameter value",
"file": "app/views/tables/show.html.erb",
- "line": 17,
+ "line": 15,
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
"code": "render(action => Current.user.tables.find(params[:id]).characters, {})",
"render_path": [
@@ -15,7 +15,7 @@
"type": "controller",
"class": "TablesController",
"method": "show",
- "line": 12,
+ "line": 13,
"file": "app/controllers/tables_controller.rb",
"rendered": {
"name": "tables/show",
@@ -41,7 +41,7 @@
"check_name": "Render",
"message": "Render path contains parameter value",
"file": "app/views/character_sheet_sections/index.html.erb",
- "line": 7,
+ "line": 13,
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
"code": "render(action => Current.user.characters.find(params[:character_id]).character_sheet_sections.top_level, {})",
"render_path": [
@@ -49,7 +49,7 @@
"type": "controller",
"class": "CharacterSheetSectionsController",
"method": "index",
- "line": 9,
+ "line": 10,
"file": "app/controllers/character_sheet_sections_controller.rb",
"rendered": {
"name": "character_sheet_sections/index",
@@ -67,8 +67,42 @@
22
],
"note": ""
+ },
+ {
+ "warning_type": "Dynamic Render Path",
+ "warning_code": 15,
+ "fingerprint": "8cc5f8414893bc6d142fda5a2a91346bfe171640647dc017315ab21724170912",
+ "check_name": "Render",
+ "message": "Render path contains parameter value",
+ "file": "app/views/events/index.html.erb",
+ "line": 4,
+ "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
+ "code": "render(action => Current.user.tables.find(params[:table_id]).dice_rolls.order(:created_at), {})",
+ "render_path": [
+ {
+ "type": "controller",
+ "class": "EventsController",
+ "method": "index",
+ "line": 11,
+ "file": "app/controllers/events_controller.rb",
+ "rendered": {
+ "name": "events/index",
+ "file": "app/views/events/index.html.erb"
+ }
+ }
+ ],
+ "location": {
+ "type": "template",
+ "template": "events/index"
+ },
+ "user_input": "params[:table_id]",
+ "confidence": "Weak",
+ "cwe_id": [
+ 22
+ ],
+ "note": ""
}
],
- "updated": "2024-06-06 14:18:01 +0100",
+ "updated": "2024-06-13 13:24:46 +0100",
"brakeman_version": "6.1.2"
}
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 7f3d53e..ee6c55b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -27,6 +27,7 @@ en:
sign_off_html: "See you soon,
The Tabletop Companion team
"
table:
overview: Overview
+ events: Events
account_verifications:
show:
success: "Thanks for verifying your email address! You can now log in."
diff --git a/config/routes.rb b/config/routes.rb
index a7c0576..b52efba 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -27,6 +27,7 @@ Rails.application.routes.draw do
resources :table_invites, only: [ :index, :edit, :update ]
resources :tables do
resources :characters, only: [ :show ]
+ resources :events, only: [ :index ]
resources :table_invites, only: [ :new, :create ]
end