1
0
Fork 0

Add actions AddressesController#index, #show

This commit is contained in:
Alex Kotov 2021-03-10 16:48:25 +05:00
parent 869381d648
commit d2b8e8dfe6
6 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,9 @@
class AddressesController < ApplicationController
def index
@addresses = Address.all
end
def show
@address = Address.find params[:id]
end
end

View file

@ -0,0 +1,9 @@
<h1>Addresses</h1>
<% if @addresses.present? %>
<ul>
<% @addresses.each do |address| %>
<li><%= link_to address.value, address %></li>
<% end %>
</ul>
<% end %>

View file

@ -0,0 +1,27 @@
<h1>Address</h1>
<dl>
<dt><%= Address.human_attribute_name :value %></dt>
<dd><%= @address.value %></dd>
<dt><%= Address.human_attribute_name :added_to_wallet %></dt>
<dd><%= @address.added_to_wallet %></dd>
<dt><%= Address.human_attribute_name :op_return_value %></dt>
<dd>
<% if @address.op_return_value.nil? %>
<i>None</i>
<% else %>
<%= @address.op_return_value %>
<% end %>
</dd>
<dt><%= Address.human_attribute_name :op_return_updated_at %></dt>
<dd>
<% if @address.op_return_updated_at %>
<%= localize @address.op_return_updated_at %>
<% else %>
<i>Never</i>
<% end %>
<dd>
</dl>

View file

@ -27,6 +27,13 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<%= link_to 'Addresses',
addresses_path,
class: "nav-link #{:active if controller_name == 'addresses'}",
'aria-current': "#{:page if controller_name == 'addresses'}" %>
</li>
<li class="nav-item">
<%= link_to 'Profiles',
profiles_path,

View file

@ -1,6 +1,8 @@
Rails.application.routes.draw do
root to: 'home#show'
resources :addresses, only: %i[index show]
resources :profiles, only: %i[index show] do
resources :followers, controller: 'profiles/followers', only: :index
resources :following, controller: 'profiles/following', only: :index

View file

@ -0,0 +1,13 @@
require "test_helper"
class AddressesControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get addresses_index_url
assert_response :success
end
test "should get show" do
get addresses_show_url
assert_response :success
end
end