mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
26 lines
741 B
Ruby
26 lines
741 B
Ruby
class SettingsController < ApplicationController
|
|
def edit
|
|
end
|
|
|
|
def update
|
|
user_params_with_family = user_params
|
|
|
|
if Current.family
|
|
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 root_path, notice: "Profile updated successfully."
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def user_params
|
|
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation,
|
|
family_attributes: [ :name, :id, :currency ])
|
|
end
|
|
end
|