Commit 33e1dc1
Changed files (6)
app
controllers
views
application
my
audits
db
app/controllers/my/audits_controller.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module My
+ class AuditsController < ApplicationController
+ def index
+ @audits = Audited::Audit.all
+ end
+ end
+end
app/views/my/audits/index.html.erb
@@ -0,0 +1,29 @@
+<div class="container">
+ <div class="row">
+ <div class="col">
+ <h1><%= t('.title') %></h1>
+ <table class="table">
+ <thead>
+ <th>Auditable</th>
+ <th>Associated</th>
+ <th>User</th>
+ <th>Version</th>
+ <th>Remote Address</th>
+ <th>Created At</th>
+ </thead>
+ <tbody>
+ <% @audits.each do |audit| %>
+ <tr>
+ <td><%= audit.auditable %></td>
+ <td><%= audit.associated %></td>
+ <td><%= audit.user %></td>
+ <td><%= audit.version %></td>
+ <td><%= audit.remote_address %></td>
+ <td><%= local_time_ago(audit.created_at) %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div>
config/locales/en.yml
@@ -25,6 +25,9 @@ en:
new:
login: Login
my:
+ audits:
+ index:
+ title: Audits
clients:
index:
new: New
config/routes.rb
@@ -18,6 +18,7 @@ Rails.application.routes.draw do
namespace :my do
resource :dashboard, only: [:show]
resource :mfa, only: [:show, :new, :edit, :create, :destroy]
+ resources :audits, only: [:index]
resources :clients, only: [:index, :new, :create]
resources :sessions, only: [:index]
end
db/schema.rb
@@ -27,19 +27,11 @@ ActiveRecord::Schema.define(version: 2018_09_23_222720) do
t.string "remote_address"
t.string "request_uuid"
t.datetime "created_at"
- t.index ["associated_type", "associated_id"], name: "associated_index"
- t.index ["auditable_type", "auditable_id", "version"], name: "auditable_index"
+ t.index ["associated_type", "associated_id"], name: "index_audits_on_associated_type_and_associated_id"
+ t.index ["auditable_type", "auditable_id", "version"], name: "index_audits_on_auditable_type_and_auditable_id_and_version"
t.index ["created_at"], name: "index_audits_on_created_at"
t.index ["request_uuid"], name: "index_audits_on_request_uuid"
- t.index ["user_id", "user_type"], name: "user_index"
- end
-
- create_table "authentications", force: :cascade do |t|
- t.integer "user_id"
- t.string "type", null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.index ["user_id"], name: "index_authentications_on_user_id"
+ t.index ["user_id", "user_type"], name: "index_audits_on_user_id_and_user_type"
end
create_table "authorizations", force: :cascade do |t|