Project show and edit
This commit is contained in:
@@ -37,6 +37,8 @@ gem "thruster", require: false
|
||||
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
||||
gem "image_processing", "~> 1.2"
|
||||
|
||||
gem 'slim'
|
||||
|
||||
group :development, :test do
|
||||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
||||
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
|
||||
|
||||
@@ -228,6 +228,9 @@ GEM
|
||||
ffi (~> 1.12)
|
||||
logger
|
||||
securerandom (0.4.1)
|
||||
slim (5.2.1)
|
||||
temple (~> 0.10.0)
|
||||
tilt (>= 2.1.0)
|
||||
solid_cable (3.0.8)
|
||||
actioncable (>= 7.2)
|
||||
activejob (>= 7.2)
|
||||
@@ -247,12 +250,14 @@ GEM
|
||||
stimulus-rails (1.3.4)
|
||||
railties (>= 6.0.0)
|
||||
stringio (3.1.7)
|
||||
temple (0.10.3)
|
||||
thor (1.3.2)
|
||||
thruster (0.1.14)
|
||||
thruster (0.1.14-aarch64-linux)
|
||||
thruster (0.1.14-arm64-darwin)
|
||||
thruster (0.1.14-x86_64-darwin)
|
||||
thruster (0.1.14-x86_64-linux)
|
||||
tilt (2.6.0)
|
||||
timeout (0.4.3)
|
||||
trilogy (2.9.0)
|
||||
turbo-rails (2.0.16)
|
||||
@@ -295,6 +300,7 @@ DEPENDENCIES
|
||||
propshaft
|
||||
puma (>= 5.0)
|
||||
rails (~> 8.0.2)
|
||||
slim
|
||||
solid_cable
|
||||
solid_cache
|
||||
solid_queue
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
class ProjectsController < ApplicationController
|
||||
before_action :fetch_project!, only: %w[show edit update destroy]
|
||||
|
||||
def index
|
||||
@projects = Project.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @project.update(params.expect(project: %i[code name description]))
|
||||
redirect_to @project
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fetch_project!
|
||||
@project = Project.find_by!(code: params[:id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module ProjectsHelper
|
||||
end
|
||||
@@ -1,3 +1,6 @@
|
||||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
||||
import "@hotwired/turbo-rails"
|
||||
import "controllers"
|
||||
|
||||
import "trix"
|
||||
import "@rails/actiontext"
|
||||
|
||||
@@ -4,4 +4,9 @@ class Project < ApplicationRecord
|
||||
has_many :tasks
|
||||
|
||||
has_rich_text :description
|
||||
|
||||
def to_param
|
||||
return unless id
|
||||
code
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
= form_with model: @project do |form|
|
||||
.field
|
||||
= form.label :code
|
||||
= form.text_field :code
|
||||
.field
|
||||
= form.label :name
|
||||
= form.text_field :name
|
||||
.field
|
||||
= form.label :description
|
||||
= form.rich_textarea :description
|
||||
.submit
|
||||
= form.submit 'Submit'
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
h1
|
||||
span Editing project
|
||||
span= @project.name
|
||||
|
||||
= render 'form'
|
||||
@@ -0,0 +1,3 @@
|
||||
ul
|
||||
- @projects.each do |project|
|
||||
li= link_to project.name, project
|
||||
@@ -0,0 +1,7 @@
|
||||
h1= @project.name
|
||||
|
||||
section= @project.description
|
||||
|
||||
section
|
||||
ul.links
|
||||
li= link_to 'Edit', edit_project_path(@project)
|
||||
@@ -5,3 +5,5 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js"
|
||||
pin "@hotwired/stimulus", to: "stimulus.min.js"
|
||||
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
||||
pin_all_from "app/javascript/controllers", under: "controllers"
|
||||
pin "trix"
|
||||
pin "@rails/actiontext", to: "actiontext.esm.js"
|
||||
|
||||
@@ -13,4 +13,6 @@ Rails.application.routes.draw do
|
||||
|
||||
# Defines the root path route ("/")
|
||||
# root "posts#index"
|
||||
|
||||
resources :projects
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user