diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index 91d0295..a98a857 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -8,6 +8,6 @@ def component_class end def component_params - params.require(@computer_name.to_sym).permit(:title, :writing_style_id, :perspective_id, :moral) + params.require(@computer_name.to_sym).permit(:title, :writing_style_id, :perspective_id, :moral, :plot, :chapters, :pages) end end diff --git a/app/models/book.rb b/app/models/book.rb index 0117a00..6be83a4 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -9,6 +9,9 @@ # updated_at :datetime not null # perspective_id :bigint # moral :text +# plot :text +# chapters :integer +# pages :integer # class Book < ApplicationRecord belongs_to :writing_style diff --git a/app/views/books/_form.html.slim b/app/views/books/_form.html.slim index 45a273c..9a19744 100644 --- a/app/views/books/_form.html.slim +++ b/app/views/books/_form.html.slim @@ -11,6 +11,14 @@ = form.label :writing_style_id, "Writing Style" = form.collection_select :writing_style_id, WritingStyle.all, :id, :name, { prompt: "Select a Writing Style" }, class: "ui dropdown" + =r ux.component_field + = form.label :chapters + = form.number_field :chapters, value: @component.chapters + + =r ux.component_field + = form.label :pages + = form.number_field :pages, value: @component.pages + = r ux.component_field = form.label :perspective_id, "Perspective" = form.collection_select :perspective_id, Perspective.all, :id, :name, { prompt: "Select a Perspective" }, class: "ui dropdown" @@ -19,6 +27,10 @@ = form.label :moral = form.text_area :moral, value: @component.moral + = r ux.component_field + = form.label :plot + = form.text_area :plot, value: @component.plot + =r ux.component_submit_field = form.submit class: 'btn-primary' diff --git a/app/views/books/show.html.slim b/app/views/books/show.html.slim new file mode 100644 index 0000000..b3dd02b --- /dev/null +++ b/app/views/books/show.html.slim @@ -0,0 +1,14 @@ +=r ux.container + =r ux.row + =r ux.column width: 16 + = turbo_frame_tag 'crud_frame' + =r ux.component_container + =r ux.component_header + = breadcrumb_parent @component_name, send(@component_list_path) + = @component.title + =r ux.component_return_action text: '< Back', url: send(@component_list_path) + =r ux.component_divider + + /=r ux.segment + / pre + / = @component.corpus diff --git a/db/migrate/20241008204514_add_plot_to_books.rb b/db/migrate/20241008204514_add_plot_to_books.rb new file mode 100644 index 0000000..dffc2cf --- /dev/null +++ b/db/migrate/20241008204514_add_plot_to_books.rb @@ -0,0 +1,7 @@ +class AddPlotToBooks < ActiveRecord::Migration[7.2] + def change + add_column :books, :plot, :text + add_column :books, :chapters, :integer + add_column :books, :pages, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 8453b5a..7c9020f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_09_24_223211) do +ActiveRecord::Schema[7.2].define(version: 2024_10_08_204514) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -31,6 +31,9 @@ t.datetime "updated_at", null: false t.bigint "perspective_id" t.text "moral" + t.text "plot" + t.integer "chapters" + t.integer "pages" t.index ["perspective_id"], name: "index_books_on_perspective_id" t.index ["writing_style_id"], name: "index_books_on_writing_style_id" end