Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting up books show view and adding more book elements #40

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions app/models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions app/views/books/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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'
14 changes: 14 additions & 0 deletions app/views/books/show.html.slim
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions db/migrate/20241008204514_add_plot_to_books.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading