Add Rails engine with browser UI at /whetrails

Mounts a Rails engine that lists app models in a sidebar and renders
the full callback/validator chain for any model. Source locations are
linked via vscode:// URIs. Condition badges and concern module tags
distinguish at-a-glance where each callback comes from.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 20:12:24 -06:00
parent 6dd78f2487
commit 286db51fcd
14 changed files with 379 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
module Whetrails
class ApplicationController < ActionController::Base
layout "whetrails/application"
protect_from_forgery with: :exception
before_action :load_all_models
private
def load_all_models
::Rails.application.eager_load!
app_root = ::Rails.root.to_s
@all_models = ::ActiveRecord::Base.descendants
.reject(&:abstract_class?)
.reject { |m| m.name.nil? }
.select { |m|
file = Object.const_source_location(m.name)&.first rescue nil
file&.start_with?(app_root)
}
.sort_by(&:name)
end
end
end

View File

@@ -0,0 +1,16 @@
module Whetrails
class ModelsController < ApplicationController
def index
if @all_models.any?
redirect_to model_path(@all_models.first.name)
end
end
def show
@model_class = params[:id].constantize
@chain = ::Whetrails::Inspector.inspect_model(@model_class)
rescue NameError
head :not_found
end
end
end