mirror of
https://github.com/System-End/highway.git
synced 2026-04-19 22:05:13 +00:00
add hours
This commit is contained in:
parent
bf673ca386
commit
1683243d2b
6 changed files with 26 additions and 4 deletions
|
|
@ -40,7 +40,7 @@ class PostsController < ApplicationController
|
|||
end
|
||||
|
||||
def post_params
|
||||
params.expect(post: [ :name, :description, :featured_image ])
|
||||
params.expect(post: [ :name, :description, :featured_image, :hours ])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ class Post < ApplicationRecord
|
|||
has_rich_text :description
|
||||
validates :description, presence: true
|
||||
validates :name, presence: true
|
||||
validates :hours, presence: true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>How many hours have you spent on this since your last update?</p>
|
||||
<%= form.label :hours %>
|
||||
<%= form.number_field :hours, class: "bg-white text-black" %>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<%= form.label :description, class: "block" %>
|
||||
|
|
@ -14,8 +20,13 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :featured_image, style: "display: block" %>
|
||||
<%= form.file_field :featured_image, accept: "image/*" %>
|
||||
<%= form.label :featured_image, style: "display: block; margin-bottom: 8px;" %>
|
||||
<div class="relative inline-block">
|
||||
<label for="post_featured_image" class="bg-blue-500 text-white px-4 py-2 rounded cursor-pointer hover:bg-blue-600">
|
||||
Choose File
|
||||
</label>
|
||||
<%= form.file_field :featured_image, id: "post_featured_image", class: "hidden", accept: "image/*" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @post.errors.any? %>
|
||||
|
|
|
|||
|
|
@ -2,5 +2,7 @@
|
|||
<%= link_to "Edit", edit_post_path(@post)%>
|
||||
|
||||
<h1><%= @post.name %></h1>
|
||||
<p>Hours spent this session:</p>
|
||||
<%= @post.hours%>
|
||||
<p><%= @post.description%></p>
|
||||
<%= image_tag @post.featured_image if @post.featured_image.attached? %>
|
||||
|
|
|
|||
5
site/db/migrate/20250427015515_add_hours_to_posts.rb
Normal file
5
site/db/migrate/20250427015515_add_hours_to_posts.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddHoursToPosts < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :posts, :hours, :integer
|
||||
end
|
||||
end
|
||||
5
site/db/schema.rb
generated
5
site/db/schema.rb
generated
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_04_26_202059) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_04_27_015515) do
|
||||
create_table "action_text_rich_texts", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.text "body"
|
||||
|
|
@ -53,6 +53,9 @@ ActiveRecord::Schema[8.0].define(version: 2025_04_26_202059) do
|
|||
t.string "name"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.text "description"
|
||||
t.string "featured_image"
|
||||
t.integer "hours"
|
||||
end
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue