mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Show validation errors in UI, otherwise fail loudly
This commit is contained in:
parent
01c877fe70
commit
e5eaac291e
1 changed files with 6 additions and 4 deletions
|
@ -14,11 +14,11 @@ module Admin
|
|||
def create
|
||||
@api_user = registrar.api_users.build(api_user_params)
|
||||
|
||||
if @api_user.save
|
||||
if @api_user.valid?
|
||||
@api_user.save!
|
||||
flash[:notice] = I18n.t('record_created')
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user)
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_create_record')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
@ -34,11 +34,13 @@ module Admin
|
|||
params[:api_user].delete(:plain_text_password)
|
||||
end
|
||||
|
||||
if @api_user.update(api_user_params)
|
||||
@api_user.attributes = api_user_params
|
||||
|
||||
if @api_user.valid?
|
||||
@api_user.save!
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user)
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue