1
0
Fork 0

Add actions AddressesController#index, #show

master
Alex Kotov 2 years ago
parent 869381d648
commit d2b8e8dfe6
  1. 9
      app/controllers/addresses_controller.rb
  2. 9
      app/views/addresses/index.html.erb
  3. 27
      app/views/addresses/show.html.erb
  4. 7
      app/views/layouts/application.html.erb
  5. 2
      config/routes.rb
  6. 13
      test/controllers/addresses_controller_test.rb

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

@ -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 %>

@ -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>

@ -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,

@ -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

@ -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