Add avatars to users
This commit is contained in:
parent
01c0ab9cc0
commit
ac0f759a4a
2
Gemfile
2
Gemfile
|
@ -20,6 +20,8 @@ gem "image_processing", "~> 1.2"
|
||||||
gem "solid_queue"
|
gem "solid_queue"
|
||||||
gem "mission_control-jobs"
|
gem "mission_control-jobs"
|
||||||
|
|
||||||
|
gem "active_storage_validations"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem "debug", platforms: %i[ mri windows ]
|
gem "debug", platforms: %i[ mri windows ]
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,6 +50,11 @@ GEM
|
||||||
erubi (~> 1.11)
|
erubi (~> 1.11)
|
||||||
rails-dom-testing (~> 2.2)
|
rails-dom-testing (~> 2.2)
|
||||||
rails-html-sanitizer (~> 1.6)
|
rails-html-sanitizer (~> 1.6)
|
||||||
|
active_storage_validations (1.1.4)
|
||||||
|
activejob (>= 5.2.0)
|
||||||
|
activemodel (>= 5.2.0)
|
||||||
|
activestorage (>= 5.2.0)
|
||||||
|
activesupport (>= 5.2.0)
|
||||||
activejob (7.1.3.3)
|
activejob (7.1.3.3)
|
||||||
activesupport (= 7.1.3.3)
|
activesupport (= 7.1.3.3)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
|
@ -314,6 +319,7 @@ PLATFORMS
|
||||||
x86_64-linux
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
active_storage_validations
|
||||||
bcrypt (~> 3.1.7)
|
bcrypt (~> 3.1.7)
|
||||||
bootsnap
|
bootsnap
|
||||||
capybara
|
capybara
|
||||||
|
|
|
@ -32,7 +32,7 @@ form, fieldset {
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldset, p, trix-editor {
|
fieldset, p, trix-editor, hr {
|
||||||
grid-column: 1/3;
|
grid-column: 1/3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,3 +59,7 @@ header nav {
|
||||||
color: var(--button-hover-text-color);
|
color: var(--button-hover-text-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ class UsersController < ApplicationController
|
||||||
:first_name,
|
:first_name,
|
||||||
:last_name,
|
:last_name,
|
||||||
:profile,
|
:profile,
|
||||||
|
:avatar,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ class User < ApplicationRecord
|
||||||
has_many :players, dependent: :destroy
|
has_many :players, dependent: :destroy
|
||||||
has_many :tables, through: :players
|
has_many :tables, through: :players
|
||||||
has_rich_text :profile
|
has_rich_text :profile
|
||||||
|
has_one_attached :avatar do |attachable|
|
||||||
|
attachable.variant :standard, resize_to_limit: [ 100, 100 ], preprocessed: true
|
||||||
|
end
|
||||||
|
validates :avatar, content_type: /\Aimage\/.*\z/,
|
||||||
|
dimension: { width: { in: 10..1000 }, height: { in: 10..1000 } }
|
||||||
|
|
||||||
has_secure_password
|
has_secure_password
|
||||||
generates_token_for :password_reset, expires_in: 4.hours do
|
generates_token_for :password_reset, expires_in: 4.hours do
|
||||||
|
|
|
@ -38,7 +38,13 @@
|
||||||
<%= display_form_errors(user, :password_confirmation) %>
|
<%= display_form_errors(user, :password_confirmation) %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<% if user.persisted? %>
|
<% if user.persisted? %>
|
||||||
|
<%= f.label :avatar %>
|
||||||
|
<%= f.file_field :avatar %>
|
||||||
|
<%= display_form_errors(user, :avatar) %>
|
||||||
|
|
||||||
<%= f.label :profile %>
|
<%= f.label :profile %>
|
||||||
<%= f.rich_text_area :profile %>
|
<%= f.rich_text_area :profile %>
|
||||||
<%= display_form_errors(user, :profile) %>
|
<%= display_form_errors(user, :profile) %>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<%= content_for :title, @user.username %>
|
<%= content_for :title, @user.username %>
|
||||||
|
|
||||||
<h2><%= @user.username %></h2>
|
<h2><%= @user.username %></h2>
|
||||||
|
<%= image_tag(url_for(@user.avatar.variant(:standard)), width: "100px", height: "100px") if @user.avatar.attached? %>
|
||||||
|
|
||||||
<aside>
|
<aside>
|
||||||
<% if @user == Current.user %>
|
<% if @user == Current.user %>
|
||||||
|
|
Loading…
Reference in New Issue