Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
add json format render
Browse files Browse the repository at this point in the history
  • Loading branch information
wuminzhe committed May 11, 2024
1 parent 0f63ee4 commit fd2519b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ def index
@messages = @messages.order(block_timestamp: :desc).page(params[:page]).per(25)
end

# GET /messages/1 or /messages/1.json
# GET /messages/:tx_or_hash
def show
@messages_count = Message.count

respond_to do |format|
format.html
format.json { render json: @message }
end
end

# GET /message?tx_or_hash=
def message
if params[:tx_or_hash].start_with?('0x')
# query from form
redirect_to message_by_tx_or_hash_path(params[:tx_or_hash])
redirect_to message_by_tx_or_hash_path(params[:tx_or_hash]) # => show
else
redirect_to messages_path
redirect_to messages_path # => index
end
end

Expand Down

0 comments on commit fd2519b

Please sign in to comment.