From 9ad922e3a14a8fd4589e1b9514dec484cd10f164 Mon Sep 17 00:00:00 2001 From: barbie-bot Date: Sat, 28 Feb 2026 15:57:50 +0000 Subject: [PATCH] Add skip_email_confirmation option; fix SQLite length validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce config.skip_email_confirmation in application.rb.dist. When set to true, new registrations are automatically confirmed without requiring email verification — useful for installations where outgoing email is not configured or for development/testing. Implemented by calling skip_confirmation! in build_resource before the record is saved, so no confirmation email is ever sent. Also fix ArgumentError raised in length validations when type_for_attribute(:column).limit returns nil, which happens with SQLite for string columns that have no explicit limit in the migration. Guard with || Float::INFINITY so the validation is effectively skipped when the database imposes no limit. Co-Authored-By: Claude Sonnet 4.6 --- app/controllers/registrations_controller.rb | 8 ++++++++ app/models/unit.rb | 4 ++-- config/application.rb.dist | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 6d6d4e5..7f1154d 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -8,6 +8,14 @@ class RegistrationsController < Devise::RegistrationsController protected + def build_resource(hash = {}) + super + # Skip the email confirmation step when the admin has opted out of it via + # config.skip_email_confirmation in application.rb. The account becomes + # active immediately so the user can sign in right after registering. + resource.skip_confirmation! if Rails.application.config.skip_email_confirmation + end + def update_resource(resource, params) # Based on update_with_password() if params[:password].blank? diff --git a/app/models/unit.rb b/app/models/unit.rb index 18ef123..6febe7e 100644 --- a/app/models/unit.rb +++ b/app/models/unit.rb @@ -12,8 +12,8 @@ class Unit < ApplicationRecord errors.add(:base, :multilevel_nesting) if base.base_id? end validates :symbol, presence: true, uniqueness: {scope: :user_id}, - length: {maximum: type_for_attribute(:symbol).limit} - validates :description, length: {maximum: type_for_attribute(:description).limit} + length: {maximum: type_for_attribute(:symbol).limit || Float::INFINITY} + validates :description, length: {maximum: type_for_attribute(:description).limit || Float::INFINITY} validates :multiplier, numericality: {equal_to: 1}, unless: :base validates :multiplier, numericality: {greater_than: 0, precision: true, scale: true}, if: :base diff --git a/config/application.rb.dist b/config/application.rb.dist index f1be478..a097379 100644 --- a/config/application.rb.dist +++ b/config/application.rb.dist @@ -54,5 +54,12 @@ module FixinMe # Sender address of account registration-related messages Devise.mailer_sender = 'noreply@localhost' + + # When set to true, new user registrations are automatically confirmed + # without requiring email verification, so accounts become active + # immediately upon sign-up. Intended for installations where outgoing + # email is not configured, or for development / testing environments. + # Defaults to false (email confirmation is required). + # config.skip_email_confirmation = true end end