Skip to content

Commit

Permalink
Rewrite callbacks for avoid using redirect_to :back (#2169)
Browse files Browse the repository at this point in the history
* Change redirect_to to render (#2113)

* Rewrite callbacks for avoid using redirect_to :back
  • Loading branch information
Maksym authored and Louis committed Apr 18, 2019
1 parent f304b07 commit 2ac0c4f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions app/controllers/admin/blockchains_controller.rb
Expand Up @@ -21,7 +21,7 @@ def create
if @blockchain.save
redirect_to admin_blockchains_path
else
flash[:alert] = @blockchain.errors.full_messages
flash[:alert] = @blockchain.errors.full_messages.first
render :show
end
end
Expand All @@ -31,8 +31,8 @@ def update
if @blockchain.update(blockchain_params)
redirect_to admin_blockchains_path
else
flash[:alert] = @blockchain.errors.full_messages
redirect_to :back
flash[:alert] = @blockchain.errors.full_messages.first
render :show
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/currencies_controller.rb
Expand Up @@ -33,7 +33,7 @@ def update
redirect_to admin_currencies_path
else
flash[:alert] = @currency.errors.full_messages.first
redirect_to :back
render :show
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/deposits/coins_controller.rb
Expand Up @@ -27,7 +27,7 @@ def update
when 'collect_fee'
deposit.collect!
end
redirect_to :back, notice: 'The deposit was successful.'
redirect_to admin_deposit_index_path(currency.id), notice: 'Deposit succesfully updated.'
end

private
Expand Down
11 changes: 6 additions & 5 deletions app/controllers/admin/deposits/fiats_controller.rb
Expand Up @@ -21,7 +21,6 @@ def new

def show
@deposit = ::Deposits::Fiat.where(currency: currency).find(params[:id])
flash.now[:notice] = 'The recharge have been successful.' if @deposit.accepted?
end

def create
Expand All @@ -35,14 +34,16 @@ def create
end

def update
deposit = ::Deposits::Fiat.where(currency: currency).find(params[:id])
@deposit = ::Deposits::Fiat.where(currency: currency).find(params[:id])
case params.fetch(:commit)
when 'Accept'
deposit.charge!
@deposit.charge!
flash.keep[:notice] = "The recharge have been successful."
when 'Reject'
deposit.reject!
@deposit.reject!
end
redirect_to :back
@deposit.reload
render :show
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/markets_controller.rb
Expand Up @@ -33,7 +33,7 @@ def update
redirect_to admin_markets_path
else
flash[:alert] = @market.errors.full_messages.first
redirect_to :back
render :show
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/admin/wallets_controller.rb
Expand Up @@ -23,7 +23,7 @@ def create
if @wallet.save
redirect_to admin_wallets_path
else
flash[:alert] = @wallet.errors.full_messages
flash[:alert] = @wallet.errors.full_messages.first
render :show
end
end
Expand All @@ -33,8 +33,8 @@ def update
if @wallet.update(wallet_params)
redirect_to admin_wallets_path
else
flash[:alert] = @wallet.errors.full_messages
redirect_to :back
flash[:alert] = @wallet.errors.full_messages.first
render :show
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/admin/withdraws/coins_controller.rb
Expand Up @@ -32,7 +32,7 @@ def update

def destroy
@withdraw.reject!
redirect_to :back, notice: 'Succesfully updated.'
redirect_to admin_withdraw_path(currency.id, @withdraw.id), notice: 'Withdrawal succesfully updated.'
end

private
Expand All @@ -47,15 +47,15 @@ def process!
@withdraw.accept!
@withdraw.process!
end
redirect_to :back, notice: 'Succesfully updated.'
redirect_to admin_withdraw_path(currency.id, @withdraw.id), notice: 'Withdrawal succesfully updated.'
end

def load!
@withdraw.transaction do
@withdraw.update!(txid: params.fetch(:txid))
@withdraw.load!
end
redirect_to :back, notice: 'Succesfully updated.'
redirect_to admin_withdraw_path(currency.id, @withdraw.id), notice: 'Withdrawal succesfully updated.'
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/withdraws/fiats_controller.rb
Expand Up @@ -26,12 +26,12 @@ def update
@withdraw.dispatch!
@withdraw.success!
end
redirect_to :back, notice: 'Withdraw successfully updated!'
redirect_to admin_withdraw_path(currency.id, @withdraw.id), notice: 'Withdrawal successfully updated!'
end

def destroy
@withdraw.reject!
redirect_to :back, notice: 'Withdraw successfully destroyed!'
redirect_to admin_withdraw_path(currency.id, @withdraw.id), notice: 'Withdrawal successfully destroyed!'
end
end
end
Expand Down

0 comments on commit 2ac0c4f

Please sign in to comment.