Files
fixin.me/config/routes.rb
barbie-bot 7904ff3ef9 Add web-based installation wizard
Replace the CLI-only setup (db:seed + manual application.rb edits)
with a web wizard shown automatically on first visit when no admin
account exists yet.

SetupController (GET/POST /setup) collects the admin e-mail and
password, a "skip e-mail confirmation" toggle, and an option to
seed the built-in default units.  Once submitted it creates the
admin User, persists the chosen options as Setting records, and
redirects to the sign-in page.

ApplicationController gains a redirect_to_setup_if_needed
before_action that catches every request (including Devise routes)
when no admin exists, so a fresh installation always lands on the
wizard rather than an empty sign-in form.

A new Setting model provides a lightweight key-value store for
runtime options that were previously hard-coded in application.rb
(e.g. skip_email_confirmation).  RegistrationsController now reads
that flag from the database instead of from the application config.

Seeds.rb is kept for headless / automated deployments and skips
admin creation when an admin already exists (idempotent), with a
comment pointing to the web wizard as the preferred path.

Also extends the SQLite nil-limit fix (|| Float::INFINITY) to the
Quantity model, which suffered the same ArgumentError as Unit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 17:19:24 +00:00

49 lines
1.5 KiB
Ruby

Rails.application.routes.draw do
# Web-based installation wizard — only reachable when no admin exists yet.
resource :setup, only: [:new, :create], controller: :setup
resources :measurements
resources :readouts, only: [:new] do
collection {get 'new/:id/discard', action: :discard, as: :discard}
end
resources :quantities, except: [:show], path_names: {new: '(/:id)/new'} do
member { post :reparent }
end
resources :units, except: [:show], path_names: {new: '(/:id)/new'} do
member { post :rebase }
end
namespace :default do
resources :units, only: [:index, :destroy] do
member { post :import, :export }
#collection { post :import_all }
end
end
# Devise does not handle properly models that require database access during loading.
# https://github.com/heartcombo/devise/issues/5786
connection = ActiveRecord::Base.connection
if connection.schema_version && connection.table_exists?(:users)
devise_for :users, path: '', path_names: {registration: 'profile'},
controllers: {registrations: :registrations}
end
resources :users, only: [:index, :show, :update] do
member { get :disguise }
collection { get :revert }
end
unauthenticated do
as :user do
root to: redirect('/sign_in')
end
end
root to: redirect('/units'), as: :user_root
direct(:source_code) { 'https://gitea.michalczyk.pro/fixin.me/fixin.me' }
direct(:issue_tracker) { 'https://gitea.michalczyk.pro/fixin.me/fixin.me/issues' }
end