Initial Rails test app
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user