From d8a27f8e4163032c76e06f313f0e1a9e953b65b7 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Thu, 13 Jun 2024 13:39:50 +0100 Subject: [PATCH] Show character sheet on table --- app/controllers/character_sheet_sections_controller.rb | 5 +++++ app/controllers/characters_controller.rb | 5 ----- app/views/character_sheet_sections/index.html.erb | 4 ++-- app/views/layouts/table.html.erb | 2 +- config/routes.rb | 4 +++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/controllers/character_sheet_sections_controller.rb b/app/controllers/character_sheet_sections_controller.rb index 2340376..24bc5f5 100644 --- a/app/controllers/character_sheet_sections_controller.rb +++ b/app/controllers/character_sheet_sections_controller.rb @@ -7,6 +7,11 @@ class CharacterSheetSectionsController < ApplicationController def index @sections = @character.character_sheet_sections.top_level @editable = ActiveModel::Type::Boolean.new.cast(params[:editable]) + if params[:table_id].present? + @table = Current.user.tables.find(params[:table_id]) + @characters = Current.user.characters.where(table: @table) + render layout: "table" + end end def new diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index d27d772..0c5ec8f 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -22,11 +22,6 @@ class CharactersController < ApplicationController end def show - if params[:table_id].present? - @table = Current.user.tables.find(params[:table_id]) - @characters = Current.user.characters.where(table: @table) - render layout: "table" - end end def edit diff --git a/app/views/character_sheet_sections/index.html.erb b/app/views/character_sheet_sections/index.html.erb index 2cd199f..1a18d08 100644 --- a/app/views/character_sheet_sections/index.html.erb +++ b/app/views/character_sheet_sections/index.html.erb @@ -3,9 +3,9 @@

<%= @character.name %>

<% if @editable %> - <%= link_to t(".stop_editing"), character_character_sheet_sections_path(editable: false) %> + <%= link_to t(".stop_editing"), url_for(editable: false) %> <% else %> - <%= link_to t(".edit"), character_character_sheet_sections_path(editable: true) %> + <%= link_to t(".edit"), url_for(editable: true) %> <% end %>
diff --git a/app/views/layouts/table.html.erb b/app/views/layouts/table.html.erb index 9d3d694..e35448f 100644 --- a/app/views/layouts/table.html.erb +++ b/app/views/layouts/table.html.erb @@ -4,7 +4,7 @@ diff --git a/config/routes.rb b/config/routes.rb index b52efba..8723c07 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,9 @@ Rails.application.routes.draw do resources :stats, only: [ :update, :destroy ] resources :table_invites, only: [ :index, :edit, :update ] resources :tables do - resources :characters, only: [ :show ] + resources :characters, only: [] do + resources :character_sheet_sections, only: [ :index ] + end resources :events, only: [ :index ] resources :table_invites, only: [ :new, :create ] end