forked from fixin.me/fixin.me
Add skip_email_confirmation option; fix SQLite length validation
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 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,14 @@ class RegistrationsController < Devise::RegistrationsController
|
|||||||
|
|
||||||
protected
|
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)
|
def update_resource(resource, params)
|
||||||
# Based on update_with_password()
|
# Based on update_with_password()
|
||||||
if params[:password].blank?
|
if params[:password].blank?
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ class Unit < ApplicationRecord
|
|||||||
errors.add(:base, :multilevel_nesting) if base.base_id?
|
errors.add(:base, :multilevel_nesting) if base.base_id?
|
||||||
end
|
end
|
||||||
validates :symbol, presence: true, uniqueness: {scope: :user_id},
|
validates :symbol, presence: true, uniqueness: {scope: :user_id},
|
||||||
length: {maximum: type_for_attribute(:symbol).limit}
|
length: {maximum: type_for_attribute(:symbol).limit || Float::INFINITY}
|
||||||
validates :description, length: {maximum: type_for_attribute(:description).limit}
|
validates :description, length: {maximum: type_for_attribute(:description).limit || Float::INFINITY}
|
||||||
validates :multiplier, numericality: {equal_to: 1}, unless: :base
|
validates :multiplier, numericality: {equal_to: 1}, unless: :base
|
||||||
validates :multiplier, numericality: {greater_than: 0, precision: true, scale: true}, if: :base
|
validates :multiplier, numericality: {greater_than: 0, precision: true, scale: true}, if: :base
|
||||||
|
|
||||||
|
|||||||
@@ -54,5 +54,12 @@ module FixinMe
|
|||||||
|
|
||||||
# Sender address of account registration-related messages
|
# Sender address of account registration-related messages
|
||||||
Devise.mailer_sender = 'noreply@localhost'
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user