add picture to user

This commit is contained in:
Torsten 2022-12-24 15:07:25 +02:00
parent 3c3882e6b3
commit e593b181ff
7 changed files with 63 additions and 53 deletions

View File

@ -48,6 +48,6 @@ class MembersController < ApplicationController
# Only allow a list of trusted parameters through. # Only allow a list of trusted parameters through.
def member_params def member_params
params.require(:member).permit(:name, :public, :bio) params.require(:member).permit(:name, :public, :bio , :picture)
end end
end end

View File

@ -5,7 +5,8 @@ class Member < ApplicationRecord
:recoverable, :rememberable, :validatable :recoverable, :rememberable, :validatable
has_rich_text :bio has_rich_text :bio
has_one_attached :picture
def admin? def admin?
true true
end end

View File

@ -1,5 +1,5 @@
.flex.flex-col = form_for @member do |f|
= form_for @member do |f| .flex.flex-col
- if @member.errors.any? - if @member.errors.any?
#error_explanation #error_explanation
%h2= "#{pluralize(@member.errors.count, "error")} prohibited this member from being saved:" %h2= "#{pluralize(@member.errors.count, "error")} prohibited this member from being saved:"
@ -7,14 +7,23 @@
- @member.errors.full_messages.each do |message| - @member.errors.full_messages.each do |message|
%li= message %li= message
.grid.grid-cols-2.m-20.gap-10
.field .field
= f.label :name = f.label :name
= f.text_field :name = f.text_field :name
.field .field
= f.label :public = f.label :public
= f.check_box :public = f.check_box :public
.field
= f.label :picture
= f.file_field :picture
-if @member.picture
%div.overflow-hidden
.my-5 Currently
= image_tag @member.picture, class: "object-contain h-40"
.field .field
= f.label :Bio = f.label :Bio
= f.rich_text_area :bio = f.rich_text_area :bio
.actions .flex.justify-center.actions
= f.submit 'Save' = f.submit 'Save'

View File

@ -1,8 +1,34 @@
.flex.justify-center .flex.justify-center.m-20
.flex.flex-col .flex.flex-col
%h1 Editing member %h1 Editing member
= render 'form' = form_for @member do |f|
.flex.flex-col
- if @member.errors.any?
#error_explanation
%h2= "#{pluralize(@member.errors.count, "error")} prohibited this member from being saved:"
%ul
- @member.errors.full_messages.each do |message|
%li= message
= link_to 'Show', @member .grid.grid-cols-2.gap-10
= link_to 'Back', members_path .field
= f.label :name
= f.text_field :name
.field
= f.label :public
= f.check_box :public
.field
= f.label :picture
= f.file_field :picture
-if @member.picture
%div.overflow-hidden
.my-5 Currently
= image_tag @member.picture, class: "object-contain h-40"
.field
= f.label :Bio
= f.rich_text_area :bio
.flex.justify-center.actions.m-10
= f.submit 'Save'
.ml-20= link_to 'Back', member_path(@member)

View File

@ -1,17 +1,16 @@
.flex.justify-center .grid.grid-cols-2.m-20.gap-10
.flex.flex-col %div
%p %b Name:
%b Name: = @member.name
= @member.name %div
%p %b Public:
%b Bio: = @member.public
= @member.bio %div.overflow-hidden.items-align-right
%p = image_tag @member.picture, class: "object-contain h-80"
%b Public: %div
= @member.public %div= @member.bio
= link_to 'Edit', edit_member_path(@member) = link_to 'Edit', edit_member_path(@member)
= link_to 'Back', members_path = form_tag( destroy_member_session_path , {method: :delete } ) do
= form_tag( destroy_member_session_path , {method: :delete } ) do %button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit}
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400{type: :submit} Sign out
Sign out

View File

@ -32,5 +32,7 @@ module HubfeenixFi
# config.eager_load_paths << Rails.root.join("extras") # config.eager_load_paths << Rails.root.join("extras")
config.autoload_paths << Rails.root.join('lib') config.autoload_paths << Rails.root.join('lib')
config.active_storage.variant_processor = :mini_magick
end end
end end

View File

@ -5,30 +5,3 @@ test:
local: local:
service: Disk service: Disk
root: <%= Rails.root.join("storage") %> root: <%= Rails.root.join("storage") %>
# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket-<%= Rails.env %>
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket-<%= Rails.env %>
# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name-<%= Rails.env %>
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]