mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Move account creation from registrar model to admin/registrars controller
This commit is contained in:
parent
c1cb598da1
commit
0a6b2fe19a
2 changed files with 7 additions and 7 deletions
|
@ -17,10 +17,15 @@ class Admin::RegistrarsController < AdminController
|
|||
def create
|
||||
@registrar = Registrar.new(registrar_params)
|
||||
|
||||
if @registrar.save
|
||||
begin
|
||||
@registrar.transaction do
|
||||
@registrar.save!
|
||||
@registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR')
|
||||
end
|
||||
|
||||
flash[:notice] = I18n.t('registrar_added')
|
||||
redirect_to [:admin, @registrar]
|
||||
else
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash.now[:alert] = I18n.t('failed_to_add_registrar')
|
||||
render 'new'
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue