mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-21 14:19:39 +02:00
25 lines
781 B
Ruby
25 lines
781 B
Ruby
class Settings::PreferencesController < ApplicationController
|
|
def edit
|
|
end
|
|
|
|
def update
|
|
preference_params_with_family = preference_params
|
|
|
|
if Current.family && preference_params[:family_attributes]
|
|
family_attributes = preference_params[:family_attributes].merge({ id: Current.family.id })
|
|
preference_params_with_family[:family_attributes] = family_attributes
|
|
end
|
|
|
|
if Current.user.update(preference_params_with_family)
|
|
redirect_to settings_preferences_path, notice: t(".success")
|
|
else
|
|
redirect_to settings_preferences_path, notice: t(".success")
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
private
|
|
def preference_params
|
|
params.require(:user).permit(family_attributes: [ :id, :currency ])
|
|
end
|
|
end
|