diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index b2ed391..ce47e25 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -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 diff --git a/app/models/member.rb b/app/models/member.rb index 48e6ef5..603bc14 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -5,7 +5,8 @@ class Member < ApplicationRecord :recoverable, :rememberable, :validatable has_rich_text :bio - + has_one_attached :picture + def admin? true end diff --git a/app/views/members/_form.html.haml b/app/views/members/_form.html.haml index a91c60e..fe415a0 100644 --- a/app/views/members/_form.html.haml +++ b/app/views/members/_form.html.haml @@ -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' diff --git a/app/views/members/edit.html.haml b/app/views/members/edit.html.haml index 8c55180..39ceeb2 100644 --- a/app/views/members/edit.html.haml +++ b/app/views/members/edit.html.haml @@ -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) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 8f89df3..eaa14d1 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -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 diff --git a/config/application.rb b/config/application.rb index d89e752..76f86dd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 diff --git a/config/storage.yml b/config/storage.yml index 4942ab6..695f17b 100644 --- a/config/storage.yml +++ b/config/storage.yml @@ -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 ]