Initial Rails test app
This commit is contained in:
2
app/controllers/application_controller.rb
Normal file
2
app/controllers/application_controller.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
end
|
||||
19
app/controllers/home_controller.rb
Normal file
19
app/controllers/home_controller.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
@db_status = check_database
|
||||
@timestamp = Time.current
|
||||
end
|
||||
|
||||
def health
|
||||
render json: { status: "ok", database: check_database, timestamp: Time.current }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_database
|
||||
ActiveRecord::Base.connection.execute("SELECT 1")
|
||||
"connected"
|
||||
rescue => e
|
||||
"error: #{e.message}"
|
||||
end
|
||||
end
|
||||
20
app/views/home/index.html.erb
Normal file
20
app/views/home/index.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<div class="container">
|
||||
<h1>Rails Test Application</h1>
|
||||
<p>Unity Platform - Coolify Deployment Test</p>
|
||||
|
||||
<h3>Status</h3>
|
||||
<div class="status <%= @db_status == 'connected' ? 'ok' : 'error' %>">
|
||||
Database: <strong><%= @db_status %></strong>
|
||||
</div>
|
||||
|
||||
<h3>Environment</h3>
|
||||
<ul>
|
||||
<li>Rails Version: <code><%= Rails.version %></code></li>
|
||||
<li>Ruby Version: <code><%= RUBY_VERSION %></code></li>
|
||||
<li>Environment: <code><%= Rails.env %></code></li>
|
||||
<li>Server Time: <code><%= @timestamp %></code></li>
|
||||
</ul>
|
||||
|
||||
<h3>Health Endpoint</h3>
|
||||
<p>Check <a href="/health">/health</a> for JSON status</p>
|
||||
</div>
|
||||
19
app/views/layouts/application.html.erb
Normal file
19
app/views/layouts/application.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Rails Test App</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; background: #f5f5f5; }
|
||||
.container { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
||||
h1 { color: #cc0000; }
|
||||
.status { padding: 10px 20px; border-radius: 5px; margin: 10px 0; }
|
||||
.status.ok { background: #d4edda; color: #155724; }
|
||||
.status.error { background: #f8d7da; color: #721c24; }
|
||||
code { background: #e9ecef; padding: 2px 6px; border-radius: 3px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user