From 988b160e657058f731967d9ac55a12f2fcfe9ba2 Mon Sep 17 00:00:00 2001 From: Christoph Marzell Date: Thu, 20 Nov 2025 12:08:34 +0100 Subject: [PATCH] add pghero --- Gemfile | 3 ++- Gemfile.lock | 3 +++ config/initializers/init_postgres.rb | 1 + config/routes.rb | 9 +++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 config/initializers/init_postgres.rb diff --git a/Gemfile b/Gemfile index a0610d6..7d4487d 100644 --- a/Gemfile +++ b/Gemfile @@ -58,4 +58,5 @@ group :development do end gem 'devise' -gem 'rufus-scheduler' \ No newline at end of file +gem 'rufus-scheduler' +gem 'pghero' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 58d1bee..038e8e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,6 +177,8 @@ GEM orm_adapter (0.5.0) pg (1.6.2-x64-mingw32) pg (1.6.2-x86_64-linux) + pghero (3.5.0) + activerecord (>= 6) pp (0.6.3) prettyprint prettyprint (0.2.0) @@ -294,6 +296,7 @@ DEPENDENCIES jquery-rails jquery-ui-rails pg (~> 1.1) + pghero puma (>= 5.0) rails (~> 7.1.5, >= 7.1.5.2) rufus-scheduler diff --git a/config/initializers/init_postgres.rb b/config/initializers/init_postgres.rb new file mode 100644 index 0000000..233b866 --- /dev/null +++ b/config/initializers/init_postgres.rb @@ -0,0 +1 @@ +puts ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pg_stat_statements;") \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index a97299f..1c9f7a6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,8 +3,17 @@ Rails.application.routes.draw do resources :entries resources :users + + root to: "entries#index" end + + authenticate :user, ->(u) { u.is_admin? } do + scope :admin do + mount PgHero::Engine, at: "pghero", as: :pghero + end + end + resources :entries do post :start_timer, on: :collection member do