From 6d132b003ebac17d666e266e42e35a1a0d6e54b0 Mon Sep 17 00:00:00 2001 From: TheNeedful-DO Date: Sat, 11 Nov 2023 15:06:47 +0000 Subject: [PATCH] Refresh token upon creation, allow delete --- app/controllers/tokens_controller.rb | 3 ++- app/views/tokens/show.html.haml | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/tokens_controller.rb b/app/controllers/tokens_controller.rb index 05e0ad71..8c52d058 100644 --- a/app/controllers/tokens_controller.rb +++ b/app/controllers/tokens_controller.rb @@ -67,7 +67,7 @@ class TokensController < ApplicationController respond_to do |format| if @token.save - format.html { redirect_to token_url(@token), notice: "Token was successfully created." } + format.html { redirect_to refresh_token_url(@token), notice: "Token was successfully created." } format.json { render :show, status: :created, location: @token } else format.html { render :new, status: :unprocessable_entity } @@ -92,6 +92,7 @@ class TokensController < ApplicationController # DELETE /tokens/1 or /tokens/1.json def destroy + authorize @token @token.destroy respond_to do |format| diff --git a/app/views/tokens/show.html.haml b/app/views/tokens/show.html.haml index 765ef807..d645479a 100644 --- a/app/views/tokens/show.html.haml +++ b/app/views/tokens/show.html.haml @@ -1,6 +1,7 @@ - if policy(@token).edit? = link_to 'Edit', edit_token_path(@token) + = link_to 'Delete', @token, method: :delete, data: { confirm: 'Are you sure?' } = link_to "Refresh Data", refresh_token_path(@token) @@ -30,5 +31,7 @@ = @token.decimals %p %b Transfer fee: - = @token.transfer_fee/(10.0**@token.decimals) + - begin + = @token.transfer_fee/(10.0**@token.decimals) + - rescue