mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
* Introduce ActiveStorage * Add active storage related service gems * Update storage.yml * Install image processing gem - sudo apt-get install libvips (required dependency) * Set default active storage service * Add profile image to user model * Amend form to allow profile images to be saved, introduce stimulus controller. * Purge image when form is blank * Update markup/stimulus controller * Add test for profile image uplaods * Add profile image validation * Use rails guide gem versions * Use correct ERB syntax and make all storage options configurable * Ensure form submits when user clears profile image * Add profile image thumbnail method * Extract profile image to a partial * Updates env.example and storage.yml * Fix bug with double form save * Add profile image to the sidenav * Update production config * Fix ERB formatting * normalize en.yml * Handle non-square images * Use pre-processing on thumbnail variant * Resovle gemfile.lock issues * Rubocop style changes --------- Signed-off-by: Christian <47796704+crobbo@users.noreply.github.com> Co-authored-by: Christian Robinson <christian@robbo.dev>
39 lines
1.1 KiB
Ruby
39 lines
1.1 KiB
Ruby
class Settings::ProfilesController < ApplicationController
|
|
def show
|
|
end
|
|
|
|
def update
|
|
user_params_with_family = user_params
|
|
|
|
if params[:user][:delete_profile_image] == "true"
|
|
Current.user.profile_image.purge
|
|
end
|
|
|
|
if Current.family && user_params_with_family[:family_attributes]
|
|
family_attributes = user_params_with_family[:family_attributes].merge({ id: Current.family.id })
|
|
user_params_with_family[:family_attributes] = family_attributes
|
|
end
|
|
|
|
if Current.user.update(user_params_with_family)
|
|
redirect_to settings_profile_path, notice: t(".success")
|
|
else
|
|
redirect_to settings_profile_path, alert: t(".file_size_error")
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if Current.user.deactivate
|
|
logout
|
|
redirect_to root_path, notice: t(".success")
|
|
else
|
|
redirect_to settings_profile_path, alert: Current.user.errors.full_messages.to_sentence
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def user_params
|
|
params.require(:user).permit(:first_name, :last_name, :profile_image,
|
|
family_attributes: [ :name, :id ])
|
|
end
|
|
end
|