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.
def member_params
params.require(:member).permit(:name, :public, :bio)
params.require(:member).permit(:name, :public, :bio , :picture)
end
end

View File

@ -5,7 +5,8 @@ class Member < ApplicationRecord
:recoverable, :rememberable, :validatable
has_rich_text :bio
has_one_attached :picture
def admin?
true
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?
#error_explanation
%h2= "#{pluralize(@member.errors.count, "error")} prohibited this member from being saved:"
@ -7,14 +7,23 @@
- @member.errors.full_messages.each do |message|
%li= message
.grid.grid-cols-2.m-20.gap-10
.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
.actions
= f.submit 'Save'
.flex.justify-center.actions
= f.submit 'Save'

View File

@ -1,8 +1,34 @@
.flex.justify-center
.flex.justify-center.m-20
.flex.flex-col
%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
= link_to 'Back', members_path
.grid.grid-cols-2.gap-10
.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
.flex.flex-col
%p
%b Name:
= @member.name
%p
%b Bio:
= @member.bio
%p
%b Public:
= @member.public
.grid.grid-cols-2.m-20.gap-10
%div
%b Name:
= @member.name
%div
%b Public:
= @member.public
%div.overflow-hidden.items-align-right
= image_tag @member.picture, class: "object-contain h-80"
%div
%div= @member.bio
= link_to 'Edit', edit_member_path(@member)
= link_to 'Back', members_path
= 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}
Sign out
= link_to 'Edit', edit_member_path(@member)
= 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}
Sign out

View File

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

View File

@ -5,30 +5,3 @@ test:
local:
service: Disk
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 ]