Module: ActiveRecord
- Extended by:
- ActiveSupport::Autoload
- Includes:
- ActiveSupport::Deprecation::DeprecatedConstantAccessor
- Defined in:
- lib/active_record.rb,
lib/active_record/base.rb,
lib/active_record/core.rb,
lib/active_record/enum.rb,
lib/active_record/type.rb,
lib/active_record/store.rb,
lib/active_record/errors.rb,
lib/active_record/result.rb,
lib/active_record/schema.rb,
lib/active_record/explain.rb,
lib/active_record/promise.rb,
lib/active_record/railtie.rb,
lib/active_record/scoping.rb,
lib/active_record/version.rb,
lib/active_record/fixtures.rb,
lib/active_record/querying.rb,
lib/active_record/relation.rb,
lib/active_record/callbacks.rb,
lib/active_record/migration.rb,
lib/active_record/signed_id.rb,
lib/active_record/timestamp.rb,
lib/active_record/token_for.rb,
lib/active_record/type/date.rb,
lib/active_record/type/json.rb,
lib/active_record/type/text.rb,
lib/active_record/type/time.rb,
lib/active_record/attributes.rb,
lib/active_record/deprecator.rb,
lib/active_record/encryption.rb,
lib/active_record/insert_all.rb,
lib/active_record/query_logs.rb,
lib/active_record/reflection.rb,
lib/active_record/suppressor.rb,
lib/active_record/coders/json.rb,
lib/active_record/gem_version.rb,
lib/active_record/inheritance.rb,
lib/active_record/integration.rb,
lib/active_record/marshalling.rb,
lib/active_record/no_touching.rb,
lib/active_record/persistence.rb,
lib/active_record/query_cache.rb,
lib/active_record/touch_later.rb,
lib/active_record/transaction.rb,
lib/active_record/translation.rb,
lib/active_record/type_caster.rb,
lib/active_record/validations.rb,
lib/active_record/aggregations.rb,
lib/active_record/associations.rb,
lib/active_record/message_pack.rb,
lib/active_record/model_schema.rb,
lib/active_record/sanitization.rb,
lib/active_record/secure_token.rb,
lib/active_record/transactions.rb,
lib/active_record/counter_cache.rb,
lib/active_record/future_result.rb,
lib/active_record/normalization.rb,
lib/active_record/schema_dumper.rb,
lib/active_record/scoping/named.rb,
lib/active_record/serialization.rb,
lib/active_record/test_fixtures.rb,
lib/active_record/type/type_map.rb,
lib/active_record/delegated_type.rb,
lib/active_record/encryption/key.rb,
lib/active_record/log_subscriber.rb,
lib/active_record/table_metadata.rb,
lib/active_record/test_databases.rb,
lib/active_record/type/date_time.rb,
lib/active_record/relation/merger.rb,
lib/active_record/scoping/default.rb,
lib/active_record/secure_password.rb,
lib/active_record/statement_cache.rb,
lib/active_record/type/serialized.rb,
lib/active_record/type_caster/map.rb,
lib/active_record/dynamic_matchers.rb,
lib/active_record/explain_registry.rb,
lib/active_record/fixture_set/file.rb,
lib/active_record/relation/batches.rb,
lib/active_record/runtime_registry.rb,
lib/active_record/schema_migration.rb,
lib/rails/generators/active_record.rb,
lib/active_record/attribute_methods.rb,
lib/active_record/encryption/cipher.rb,
lib/active_record/encryption/config.rb,
lib/active_record/encryption/errors.rb,
lib/active_record/encryption/scheme.rb,
lib/active_record/internal_metadata.rb,
lib/active_record/nested_attributes.rb,
lib/active_record/coders/yaml_column.rb,
lib/active_record/encryption/context.rb,
lib/active_record/encryption/message.rb,
lib/active_record/explain_subscriber.rb,
lib/active_record/locking/optimistic.rb,
lib/active_record/validations/length.rb,
lib/active_record/associations/errors.rb,
lib/active_record/connection_adapters.rb,
lib/active_record/connection_handling.rb,
lib/active_record/encryption/contexts.rb,
lib/active_record/legacy_yaml_adapter.rb,
lib/active_record/locking/pessimistic.rb,
lib/active_record/readonly_attributes.rb,
lib/active_record/relation/delegation.rb,
lib/active_record/validations/absence.rb,
lib/active_record/association_relation.rb,
lib/active_record/attribute_assignment.rb,
lib/active_record/autosave_association.rb,
lib/active_record/encryption/encryptor.rb,
lib/active_record/migration/join_table.rb,
lib/active_record/query_logs_formatter.rb,
lib/active_record/railties/job_runtime.rb,
lib/active_record/relation/from_clause.rb,
lib/active_record/tasks/database_tasks.rb,
lib/active_record/validations/presence.rb,
lib/active_record/encryption/properties.rb,
lib/active_record/fixture_set/table_row.rb,
lib/active_record/relation/calculations.rb,
lib/active_record/relation/where_clause.rb,
lib/active_record/type/unsigned_integer.rb,
lib/active_record/associations/preloader.rb,
lib/active_record/attribute_methods/read.rb,
lib/active_record/fixture_set/table_rows.rb,
lib/active_record/relation/query_methods.rb,
lib/active_record/relation/spawn_methods.rb,
lib/active_record/type/internal/timezone.rb,
lib/active_record/type_caster/connection.rb,
lib/active_record/validations/associated.rb,
lib/active_record/validations/uniqueness.rb,
lib/active_record/attribute_methods/dirty.rb,
lib/active_record/attribute_methods/query.rb,
lib/active_record/attribute_methods/write.rb,
lib/active_record/database_configurations.rb,
lib/active_record/encryption/configurable.rb,
lib/active_record/encryption/key_provider.rb,
lib/active_record/migration/compatibility.rb,
lib/active_record/relation/finder_methods.rb,
lib/active_record/associations/association.rb,
lib/active_record/coders/column_serializer.rb,
lib/active_record/encryption/key_generator.rb,
lib/active_record/relation/query_attribute.rb,
lib/active_record/testing/query_assertions.rb,
lib/active_record/validations/numericality.rb,
lib/active_record/associations/nested_error.rb,
lib/active_record/encryption/null_encryptor.rb,
lib/active_record/middleware/shard_selector.rb,
lib/active_record/type/hash_lookup_type_map.rb,
lib/active_record/associations/alias_tracker.rb,
lib/active_record/connection_adapters/column.rb,
lib/active_record/fixture_set/model_metadata.rb,
lib/active_record/migration/command_recorder.rb,
lib/active_record/migration/default_strategy.rb,
lib/active_record/relation/predicate_builder.rb,
lib/active_record/tasks/mysql_database_tasks.rb,
lib/active_record/type/decimal_without_scale.rb,
lib/rails/generators/active_record/migration.rb,
lib/active_record/railties/controller_runtime.rb,
lib/active_record/tasks/sqlite_database_tasks.rb,
lib/active_record/associations/join_dependency.rb,
lib/active_record/associations/preloader/batch.rb,
lib/active_record/asynchronous_queries_tracker.rb,
lib/active_record/encryption/cipher/aes256_gcm.rb,
lib/active_record/middleware/database_selector.rb,
lib/active_record/migration/execution_strategy.rb,
lib/active_record/associations/collection_proxy.rb,
lib/active_record/associations/preloader/branch.rb,
lib/active_record/attribute_methods/primary_key.rb,
lib/active_record/destroy_association_async_job.rb,
lib/active_record/encryption/encryptable_record.rb,
lib/active_record/encryption/encrypted_fixtures.rb,
lib/active_record/encryption/message_serializer.rb,
lib/active_record/relation/record_fetch_warning.rb,
lib/active_record/associations/association_scope.rb,
lib/active_record/type/adapter_specific_registry.rb,
lib/active_record/attribute_methods/serialization.rb,
lib/active_record/connection_adapters/pool_config.rb,
lib/active_record/tasks/postgresql_database_tasks.rb,
lib/active_record/associations/has_one_association.rb,
lib/active_record/associations/through_association.rb,
lib/active_record/connection_adapters/deduplicable.rb,
lib/active_record/connection_adapters/mysql/column.rb,
lib/active_record/connection_adapters/pool_manager.rb,
lib/active_record/connection_adapters/schema_cache.rb,
lib/active_record/associations/has_many_association.rb,
lib/active_record/associations/singular_association.rb,
lib/active_record/connection_adapters/mysql/quoting.rb,
lib/active_record/relation/batches/batch_enumerator.rb,
lib/active_record/associations/preloader/association.rb,
lib/active_record/attribute_methods/before_type_cast.rb,
lib/active_record/connection_adapters/mysql2_adapter.rb,
lib/active_record/connection_adapters/postgresql/oid.rb,
lib/active_record/connection_adapters/sqlite3/column.rb,
lib/active_record/connection_adapters/statement_pool.rb,
lib/active_record/database_configurations/url_config.rb,
lib/active_record/disable_joins_association_relation.rb,
lib/active_record/associations/belongs_to_association.rb,
lib/active_record/associations/collection_association.rb,
lib/active_record/connection_adapters/sqlite3/quoting.rb,
lib/active_record/connection_adapters/sqlite3_adapter.rb,
lib/active_record/connection_adapters/trilogy_adapter.rb,
lib/active_record/database_configurations/hash_config.rb,
lib/active_record/encryption/auto_filtered_parameters.rb,
lib/active_record/encryption/encrypted_attribute_type.rb,
lib/active_record/encryption/read_only_null_encryptor.rb,
lib/active_record/connection_adapters/abstract/quoting.rb,
lib/active_record/connection_adapters/abstract_adapter.rb,
lib/active_record/connection_adapters/postgresql/utils.rb,
lib/active_record/encryption/encrypting_only_encryptor.rb,
lib/active_record/connection_adapters/postgresql/column.rb,
lib/active_record/connection_adapters/sql_type_metadata.rb,
lib/active_record/encryption/deterministic_key_provider.rb,
lib/active_record/middleware/database_selector/resolver.rb,
lib/active_record/associations/join_dependency/join_base.rb,
lib/active_record/associations/join_dependency/join_part.rb,
lib/active_record/attribute_methods/time_zone_conversion.rb,
lib/active_record/connection_adapters/postgresql/oid/bit.rb,
lib/active_record/connection_adapters/postgresql/oid/oid.rb,
lib/active_record/connection_adapters/postgresql/oid/xml.rb,
lib/active_record/connection_adapters/postgresql/quoting.rb,
lib/active_record/connection_adapters/postgresql_adapter.rb,
lib/active_record/encryption/derived_secret_key_provider.rb,
lib/active_record/migration/pending_migration_connection.rb,
lib/rails/generators/active_record/model/model_generator.rb,
lib/active_record/attribute_methods/composite_primary_key.rb,
lib/active_record/connection_adapters/abstract/savepoints.rb,
lib/active_record/connection_adapters/mysql/schema_dumper.rb,
lib/active_record/connection_adapters/mysql/type_metadata.rb,
lib/active_record/connection_adapters/postgresql/oid/cidr.rb,
lib/active_record/connection_adapters/postgresql/oid/date.rb,
lib/active_record/connection_adapters/postgresql/oid/enum.rb,
lib/active_record/connection_adapters/postgresql/oid/inet.rb,
lib/active_record/connection_adapters/postgresql/oid/uuid.rb,
lib/active_record/database_configurations/database_config.rb,
lib/active_record/associations/has_one_through_association.rb,
lib/active_record/connection_adapters/abstract/query_cache.rb,
lib/active_record/connection_adapters/abstract/transaction.rb,
lib/active_record/connection_adapters/postgresql/oid/array.rb,
lib/active_record/connection_adapters/postgresql/oid/bytea.rb,
lib/active_record/connection_adapters/postgresql/oid/jsonb.rb,
lib/active_record/connection_adapters/postgresql/oid/money.rb,
lib/active_record/connection_adapters/postgresql/oid/point.rb,
lib/active_record/connection_adapters/postgresql/oid/range.rb,
lib/active_record/relation/predicate_builder/array_handler.rb,
lib/active_record/relation/predicate_builder/range_handler.rb,
lib/active_record/associations/has_many_through_association.rb,
lib/active_record/connection_adapters/mysql/schema_creation.rb,
lib/active_record/connection_adapters/postgresql/oid/hstore.rb,
lib/active_record/connection_adapters/postgresql/oid/vector.rb,
lib/active_record/connection_adapters/sqlite3/schema_dumper.rb,
lib/active_record/encryption/extended_deterministic_queries.rb,
lib/active_record/associations/preloader/through_association.rb,
lib/active_record/connection_adapters/abstract/schema_dumper.rb,
lib/active_record/connection_adapters/abstract_mysql_adapter.rb,
lib/active_record/connection_adapters/postgresql/oid/decimal.rb,
lib/active_record/connection_adapters/postgresql/oid/macaddr.rb,
lib/active_record/encryption/message_pack_message_serializer.rb,
lib/active_record/connection_adapters/mysql/schema_statements.rb,
lib/active_record/connection_adapters/postgresql/oid/interval.rb,
lib/active_record/connection_adapters/sqlite3/schema_creation.rb,
lib/active_record/encryption/envelope_encryption_key_provider.rb,
lib/active_record/relation/predicate_builder/relation_handler.rb,
lib/active_record/associations/disable_joins_association_scope.rb,
lib/active_record/connection_adapters/abstract/connection_pool.rb,
lib/active_record/connection_adapters/abstract/database_limits.rb,
lib/active_record/connection_adapters/abstract/schema_creation.rb,
lib/active_record/connection_adapters/mysql/schema_definitions.rb,
lib/active_record/connection_adapters/postgresql/oid/date_time.rb,
lib/active_record/connection_adapters/postgresql/oid/timestamp.rb,
lib/active_record/connection_adapters/postgresql/schema_dumper.rb,
lib/active_record/connection_adapters/postgresql/type_metadata.rb,
lib/rails/generators/active_record/multi_db/multi_db_generator.rb,
lib/active_record/associations/join_dependency/join_association.rb,
lib/active_record/connection_adapters/mysql/database_statements.rb,
lib/active_record/connection_adapters/sqlite3/schema_statements.rb,
lib/active_record/middleware/database_selector/resolver/session.rb,
lib/active_record/connection_adapters/abstract/schema_statements.rb,
lib/active_record/connection_adapters/mysql2/database_statements.rb,
lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb,
lib/active_record/connection_adapters/postgresql/schema_creation.rb,
lib/active_record/connection_adapters/sqlite3/schema_definitions.rb,
lib/rails/generators/active_record/migration/migration_generator.rb,
lib/active_record/associations/belongs_to_polymorphic_association.rb,
lib/active_record/connection_adapters/abstract/connection_handler.rb,
lib/active_record/connection_adapters/abstract/schema_definitions.rb,
lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb,
lib/active_record/connection_adapters/sqlite3/database_statements.rb,
lib/active_record/connection_adapters/trilogy/database_statements.rb,
lib/active_record/database_configurations/connection_url_resolver.rb,
lib/active_record/relation/predicate_builder/basic_object_handler.rb,
lib/active_record/connection_adapters/abstract/database_statements.rb,
lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb,
lib/active_record/connection_adapters/postgresql/schema_statements.rb,
lib/active_record/connection_adapters/postgresql/schema_definitions.rb,
lib/active_record/connection_adapters/abstract/connection_pool/queue.rb,
lib/active_record/connection_adapters/postgresql/database_statements.rb,
lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb,
lib/active_record/relation/predicate_builder/association_query_value.rb,
lib/active_record/relation/predicate_builder/polymorphic_array_value.rb,
lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb,
lib/active_record/connection_adapters/postgresql/referential_integrity.rb,
lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb,
lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb,
lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb,
lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb,
lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb,
lib/rails/generators/active_record/application_record/application_record_generator.rb
Overview
:markup: markdown
Defined Under Namespace
Modules: Aggregations, Assertions, Associations, AttributeAssignment, AttributeMethods, Attributes, AutosaveAssociation, Batches, Calculations, Callbacks, Coders, ConnectionAdapters, ConnectionHandling, Core, CounterCache, DelegatedType, Delegation, DynamicMatchers, Encryption, Enum, Explain, FinderMethods, Generators, Inheritance, Integration, LegacyYamlAdapter, Locking, Marshalling, MessagePack, Middleware, ModelSchema, NestedAttributes, NoTouching, Normalization, Persistence, QueryLogs, QueryMethods, Querying, Railties, ReadonlyAttributes, Reflection, RuntimeRegistry, Sanitization, Scoping, SecurePassword, SecureToken, Serialization, SignedId, SpawnMethods, Store, Suppressor, Tasks, TestDatabases, TestFixtures, Timestamp, TokenFor, TouchLater, Transactions, Translation, Type, TypeCaster, VERSION, Validations Classes: ActiveRecordError, AdapterError, AdapterNotFound, AdapterNotSpecified, AdapterTimeout, AmbiguousSourceReflectionForThroughAssociation, AssociationNotFoundError, AssociationRelation, AssociationTypeMismatch, AsynchronousQueriesTracker, AsynchronousQueryInsideTransactionError, AttributeAssignmentError, Base, CompositePrimaryKeyMismatchError, ConcurrentMigrationError, ConfigurationError, ConnectionFailed, ConnectionNotDefined, ConnectionNotEstablished, ConnectionTimeoutError, DangerousAttributeError, DatabaseAlreadyExists, DatabaseConfigurations, DatabaseConnectionError, DatabaseVersionError, Deadlocked, DeleteRestrictionError, DestroyAssociationAsyncError, DestroyAssociationAsyncJob, DisableJoinsAssociationRelation, DuplicateMigrationNameError, DuplicateMigrationVersionError, EagerLoadPolymorphicError, EnvironmentMismatchError, EnvironmentStorageError, ExclusiveConnectionTimeoutError, ExplainRegistry, ExplainSubscriber, Fixture, FixtureClassNotFound, FixtureSet, FutureResult, HasManyThroughAssociationNotFoundError, HasManyThroughAssociationPointlessSourceTypeError, HasManyThroughAssociationPolymorphicSourceError, HasManyThroughAssociationPolymorphicThroughError, HasManyThroughCantAssociateThroughHasOneOrManyReflection, HasManyThroughNestedAssociationsAreReadonly, HasManyThroughOrderError, HasManyThroughSourceAssociationNotFoundError, HasOneAssociationPolymorphicThroughError, HasOneThroughCantAssociateThroughCollection, HasOneThroughCantAssociateThroughHasOneOrManyReflection, HasOneThroughNestedAssociationsAreReadonly, IllegalMigrationNameError, InsertAll, InternalMetadata, InvalidForeignKey, InvalidMigrationTimestampError, InverseOfAssociationNotFoundError, InverseOfAssociationRecursiveError, IrreversibleMigration, IrreversibleOrderError, LockWaitTimeout, LogSubscriber, Migration, MigrationContext, MigrationError, MigrationProxy, Migrator, MismatchedForeignKey, MultiparameterAssignmentErrors, NoDatabaseError, NoEnvironmentInSchemaError, NotNullViolation, PendingMigrationConnection, PendingMigrationError, Point, PredicateBuilder, PreparedStatementCacheExpired, PreparedStatementInvalid, Promise, ProtectedEnvironmentError, QueryAborted, QueryCache, QueryCanceled, Railtie, RangeError, ReadOnlyError, ReadOnlyRecord, ReadonlyAttributeError, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, Relation, Result, Rollback, SQLWarning, Schema, SchemaDumper, SchemaMigration, SerializationFailure, SerializationTypeMismatch, SoleRecordExceeded, StaleObjectError, StatementCache, StatementInvalid, StatementTimeout, StrictLoadingViolationError, SubclassNotFound, TableMetadata, TableNotSpecified, ThroughCantAssociateThroughHasOneOrManyReflection, ThroughNestedAssociationsAreReadonly, Transaction, TransactionIsolationError, TransactionRollbackError, TypeConflictError, UnknownAttributeReference, UnknownMigrationVersionError, UnknownPrimaryKey, UnmodifiableRelation, ValueTooLong, WrappedDatabaseException
Constant Summary collapse
- UnknownAttributeError =
Raised when unknown attributes are supplied via mass assignment.
ActiveModel::UnknownAttributeError
Instance Attribute Summary collapse
-
#action_on_strict_loading_violation ⇒ Object
:singleton-method: action_on_strict_loading_violation Set the application to log or raise when an association violates strict loading.
-
#application_record_class ⇒ Object
Returns the value of attribute application_record_class.
-
#async_query_executor ⇒ Object
:singleton-method: async_query_executor Sets the async_query_executor for an application.
-
#before_committed_on_all_records ⇒ Object
Returns the value of attribute before_committed_on_all_records.
-
#belongs_to_required_validates_foreign_key ⇒ Object
Returns the value of attribute belongs_to_required_validates_foreign_key.
-
#database_cli ⇒ Object
Returns the value of attribute database_cli.
-
#db_warnings_action ⇒ Object
readonly
:singleton-method: db_warnings_action The action to take when database query produces warning.
-
#db_warnings_ignore ⇒ Object
:singleton-method: db_warnings_ignore Specify allowlist of database warnings.
-
#default_timezone ⇒ Object
readonly
Returns the value of attribute default_timezone.
-
#disable_prepared_statements ⇒ Object
Returns the value of attribute disable_prepared_statements.
-
#dump_schema_after_migration ⇒ Object
:singleton-method: dump_schema_after_migration Specify whether schema dump should happen at the end of the bin/rails db:migrate command.
-
#dump_schemas ⇒ Object
:singleton-method: dump_schemas Specifies which database schemas to dump when calling db:schema:dump.
-
#error_on_ignored_order ⇒ Object
:singleton-method: error_on_ignored_order Specifies if an error should be raised if the query has an order being ignored when doing batch queries.
-
#generate_secure_token_on ⇒ Object
:singleton-method: generate_secure_token_on Controls when to generate a value for
has_secure_token
declarations. -
#index_nested_attribute_errors ⇒ Object
Returns the value of attribute index_nested_attribute_errors.
-
#lazily_load_schema_cache ⇒ Object
:singleton-method: lazily_load_schema_cache Lazily load the schema cache.
-
#maintain_test_schema ⇒ Object
Returns the value of attribute maintain_test_schema.
-
#migration_strategy ⇒ Object
:singleton-method: migration_strategy Specify strategy to use for executing migrations.
-
#permanent_connection_checkout ⇒ Object
readonly
Returns the value of attribute permanent_connection_checkout.
-
#protocol_adapters ⇒ Object
:singleton-method: protocol_adapters Provides a mapping between database protocols/DBMSs and the underlying database adapter to be used.
-
#query_transformers ⇒ Object
Returns the value of attribute query_transformers.
-
#queues ⇒ Object
:singleton-method: queues.
-
#raise_int_wider_than_64bit ⇒ Object
:singleton-method: raise_int_wider_than_64bit Application configurable boolean that denotes whether or not to raise an exception when the PostgreSQLAdapter is provided with an integer that is wider than signed 64bit representation.
-
#raise_on_assign_to_attr_readonly ⇒ Object
Returns the value of attribute raise_on_assign_to_attr_readonly.
-
#reading_role ⇒ Object
Returns the value of attribute reading_role.
-
#run_after_transaction_callbacks_in_order_defined ⇒ Object
Returns the value of attribute run_after_transaction_callbacks_in_order_defined.
-
#schema_cache_ignored_tables ⇒ Object
:singleton-method: schema_cache_ignored_tables A list of tables or regex’s to match tables to ignore when dumping the schema cache.
-
#schema_format ⇒ Object
:singleton-method: schema_format Specifies the format to use when dumping the database schema with Rails’ Rakefile.
-
#timestamped_migrations ⇒ Object
:singleton-method: timestamped_migrations Specify whether or not to use timestamps for migration versions.
-
#use_yaml_unsafe_load ⇒ Object
:singleton-method: use_yaml_unsafe_load Application configurable boolean that instructs the YAML Coder to use an unsafe load if set to true.
-
#validate_migration_timestamps ⇒ Object
:singleton-method: validate_migration_timestamps Specify whether or not to validate migration timestamps.
-
#verbose_query_logs ⇒ Object
:singleton-method: verbose_query_logs.
-
#verify_foreign_keys_for_fixtures ⇒ Object
:singleton-method: verify_foreign_keys_for_fixtures If true, Rails will verify all foreign keys in the database after loading fixtures.
-
#warn_on_records_fetched_greater_than ⇒ Object
:singleton-method: warn_on_records_fetched_greater_than Specify a threshold for the size of query result sets.
-
#writing_role ⇒ Object
Returns the value of attribute writing_role.
-
#yaml_column_permitted_classes ⇒ Object
:singleton-method: yaml_column_permitted_classes Application configurable array that provides additional permitted classes to Psych safe_load in the YAML Coder.
Class Method Summary collapse
-
.after_all_transactions_commit(&block) ⇒ Object
Registers a block to be called after all the current transactions have been committed.
-
.all_open_transactions ⇒ Object
:nodoc:.
- .allow_deprecated_singular_associations_name ⇒ Object
- .allow_deprecated_singular_associations_name=(value) ⇒ Object
- .commit_transaction_on_non_local_return ⇒ Object
- .commit_transaction_on_non_local_return=(value) ⇒ Object
- .db_warnings_action=(action) ⇒ Object
-
.default_timezone=(default_timezone) ⇒ Object
Determines whether to use Time.utc (using :utc) or Time.local (using :local) when pulling dates and times from the database.
-
.deprecator ⇒ Object
:nodoc:.
-
.disconnect_all! ⇒ Object
Explicitly closes all database connections in all pools.
- .eager_load! ⇒ Object
-
.gem_version ⇒ Object
Returns the currently loaded version of Active Record as a
Gem::Version
. -
.global_executor_concurrency ⇒ Object
:nodoc:.
-
.global_executor_concurrency=(global_executor_concurrency) ⇒ Object
Set the
global_executor_concurrency
. -
.global_thread_pool_async_query_executor ⇒ Object
:nodoc:.
- .legacy_connection_handling=(_) ⇒ Object
- .marshalling_format_version ⇒ Object
- .marshalling_format_version=(value) ⇒ Object
-
.permanent_connection_checkout=(value) ⇒ Object
Defines whether
ActiveRecord::Base.connection
is allowed, deprecated, or entirely disallowed. -
.schema_cache_ignored_table?(table_name) ⇒ Boolean
Checks to see if the
table_name
is ignored by checking against theschema_cache_ignored_tables
option. -
.version ⇒ Object
Returns the currently loaded version of Active Record as a
Gem::Version
.
Instance Attribute Details
#action_on_strict_loading_violation ⇒ Object
:singleton-method: action_on_strict_loading_violation Set the application to log or raise when an association violates strict loading. Defaults to :raise.
392 393 394 |
# File 'lib/active_record.rb', line 392 def action_on_strict_loading_violation @action_on_strict_loading_violation end |
#application_record_class ⇒ Object
Returns the value of attribute application_record_class.
385 386 387 |
# File 'lib/active_record.rb', line 385 def application_record_class @application_record_class end |
#async_query_executor ⇒ Object
:singleton-method: async_query_executor Sets the async_query_executor for an application. By default the thread pool executor set to nil
which will not run queries in the background. Applications must configure a thread pool executor to use this feature. Options are:
* nil - Does not initialize a thread pool executor. Any async calls will be
run in the foreground.
* :global_thread_pool - Initializes a single +Concurrent::ThreadPoolExecutor+
that uses the +async_query_concurrency+ for the +max_threads+ value.
* :multi_thread_pool - Initializes a +Concurrent::ThreadPoolExecutor+ for each
database connection. The initializer values are defined in the configuration hash.
291 292 293 |
# File 'lib/active_record.rb', line 291 def async_query_executor @async_query_executor end |
#before_committed_on_all_records ⇒ Object
Returns the value of attribute before_committed_on_all_records.
356 357 358 |
# File 'lib/active_record.rb', line 356 def before_committed_on_all_records @before_committed_on_all_records end |
#belongs_to_required_validates_foreign_key ⇒ Object
Returns the value of attribute belongs_to_required_validates_foreign_key.
353 354 355 |
# File 'lib/active_record.rb', line 353 def belongs_to_required_validates_foreign_key @belongs_to_required_validates_foreign_key end |
#database_cli ⇒ Object
Returns the value of attribute database_cli.
211 212 213 |
# File 'lib/active_record.rb', line 211 def database_cli @database_cli end |
#db_warnings_action ⇒ Object (readonly)
:singleton-method: db_warnings_action The action to take when database query produces warning. Must be one of :ignore, :log, :raise, :report, or a custom proc. The default is :ignore.
233 234 235 |
# File 'lib/active_record.rb', line 233 def db_warnings_action @db_warnings_action end |
#db_warnings_ignore ⇒ Object
:singleton-method: db_warnings_ignore Specify allowlist of database warnings.
262 263 264 |
# File 'lib/active_record.rb', line 262 def db_warnings_ignore @db_warnings_ignore end |
#default_timezone ⇒ Object (readonly)
Returns the value of attribute default_timezone.
214 215 216 |
# File 'lib/active_record.rb', line 214 def default_timezone @default_timezone end |
#disable_prepared_statements ⇒ Object
Returns the value of attribute disable_prepared_statements.
182 183 184 |
# File 'lib/active_record.rb', line 182 def disable_prepared_statements @disable_prepared_statements end |
#dump_schema_after_migration ⇒ Object
:singleton-method: dump_schema_after_migration Specify whether schema dump should happen at the end of the bin/rails db:migrate command. This is true by default, which is useful for the development environment. This should ideally be false in the production environment where dumping schema is rarely needed.
440 441 442 |
# File 'lib/active_record.rb', line 440 def dump_schema_after_migration @dump_schema_after_migration end |
#dump_schemas ⇒ Object
:singleton-method: dump_schemas Specifies which database schemas to dump when calling db:schema:dump. If the value is :schema_search_path (the default), any schemas listed in schema_search_path are dumped. Use :all to dump all schemas regardless of schema_search_path, or a string of comma separated schemas for a custom list.
450 451 452 |
# File 'lib/active_record.rb', line 450 def dump_schemas @dump_schemas end |
#error_on_ignored_order ⇒ Object
:singleton-method: error_on_ignored_order Specifies if an error should be raised if the query has an order being ignored when doing batch queries. Useful in applications where the scope being ignored is error-worthy, rather than a warning.
411 412 413 |
# File 'lib/active_record.rb', line 411 def error_on_ignored_order @error_on_ignored_order end |
#generate_secure_token_on ⇒ Object
:singleton-method: generate_secure_token_on Controls when to generate a value for has_secure_token
declarations. Defaults to :create
.
505 506 507 |
# File 'lib/active_record.rb', line 505 def generate_secure_token_on @generate_secure_token_on end |
#index_nested_attribute_errors ⇒ Object
Returns the value of attribute index_nested_attribute_errors.
329 330 331 |
# File 'lib/active_record.rb', line 329 def index_nested_attribute_errors @index_nested_attribute_errors end |
#lazily_load_schema_cache ⇒ Object
:singleton-method: lazily_load_schema_cache Lazily load the schema cache. This option will load the schema cache when a connection is established rather than on boot.
189 190 191 |
# File 'lib/active_record.rb', line 189 def lazily_load_schema_cache @lazily_load_schema_cache end |
#maintain_test_schema ⇒ Object
Returns the value of attribute maintain_test_schema.
347 348 349 |
# File 'lib/active_record.rb', line 347 def maintain_test_schema @maintain_test_schema end |
#migration_strategy ⇒ Object
:singleton-method: migration_strategy Specify strategy to use for executing migrations.
431 432 433 |
# File 'lib/active_record.rb', line 431 def migration_strategy @migration_strategy end |
#permanent_connection_checkout ⇒ Object (readonly)
Returns the value of attribute permanent_connection_checkout.
319 320 321 |
# File 'lib/active_record.rb', line 319 def permanent_connection_checkout @permanent_connection_checkout end |
#protocol_adapters ⇒ Object
:singleton-method: protocol_adapters Provides a mapping between database protocols/DBMSs and the underlying database adapter to be used. This is used only by the DATABASE_URL
environment variable.
Example
DATABASE_URL="mysql://myuser:mypass@localhost/somedatabase"
The above URL specifies that MySQL is the desired protocol/DBMS, and the application configuration can then decide which adapter to use. For this example the default mapping is from mysql
to mysql2
, but :trilogy
is also supported.
ActiveRecord.protocol_adapters.mysql = "mysql2"
The protocols names are arbitrary, and external database adapters can be registered and set here.
535 536 537 |
# File 'lib/active_record.rb', line 535 def protocol_adapters @protocol_adapters end |
#query_transformers ⇒ Object
Returns the value of attribute query_transformers.
476 477 478 |
# File 'lib/active_record.rb', line 476 def query_transformers @query_transformers end |
#queues ⇒ Object
:singleton-method: queues
Specifies the names of the queues used by background jobs.
344 345 346 |
# File 'lib/active_record.rb', line 344 def queues @queues end |
#raise_int_wider_than_64bit ⇒ Object
:singleton-method: raise_int_wider_than_64bit Application configurable boolean that denotes whether or not to raise an exception when the PostgreSQLAdapter is provided with an integer that is wider than signed 64bit representation
491 492 493 |
# File 'lib/active_record.rb', line 491 def raise_int_wider_than_64bit @raise_int_wider_than_64bit end |
#raise_on_assign_to_attr_readonly ⇒ Object
Returns the value of attribute raise_on_assign_to_attr_readonly.
350 351 352 |
# File 'lib/active_record.rb', line 350 def raise_on_assign_to_attr_readonly @raise_on_assign_to_attr_readonly end |
#reading_role ⇒ Object
Returns the value of attribute reading_role.
268 269 270 |
# File 'lib/active_record.rb', line 268 def reading_role @reading_role end |
#run_after_transaction_callbacks_in_order_defined ⇒ Object
Returns the value of attribute run_after_transaction_callbacks_in_order_defined.
359 360 361 |
# File 'lib/active_record.rb', line 359 def run_after_transaction_callbacks_in_order_defined @run_after_transaction_callbacks_in_order_defined end |
#schema_cache_ignored_tables ⇒ Object
:singleton-method: schema_cache_ignored_tables A list of tables or regex’s to match tables to ignore when dumping the schema cache. For example if this is set to [/^_/] the schema cache will not dump tables named with an underscore.
197 198 199 |
# File 'lib/active_record.rb', line 197 def schema_cache_ignored_tables @schema_cache_ignored_tables end |
#schema_format ⇒ Object
:singleton-method: schema_format Specifies the format to use when dumping the database schema with Rails’ Rakefile. If :sql, the schema is dumped as (potentially database- specific) SQL statements. If :ruby, the schema is dumped as an ActiveRecord::Schema file which can be loaded into any database that supports migrations. Use :ruby if you want to have different database adapters for, e.g., your development and test environments.
403 404 405 |
# File 'lib/active_record.rb', line 403 def schema_format @schema_format end |
#timestamped_migrations ⇒ Object
:singleton-method: timestamped_migrations Specify whether or not to use timestamps for migration versions
417 418 419 |
# File 'lib/active_record.rb', line 417 def @timestamped_migrations end |
#use_yaml_unsafe_load ⇒ Object
:singleton-method: use_yaml_unsafe_load Application configurable boolean that instructs the YAML Coder to use an unsafe load if set to true.
483 484 485 |
# File 'lib/active_record.rb', line 483 def use_yaml_unsafe_load @use_yaml_unsafe_load end |
#validate_migration_timestamps ⇒ Object
:singleton-method: validate_migration_timestamps Specify whether or not to validate migration timestamps. When set, an error will be raised if a timestamp is more than a day ahead of the timestamp associated with the current time. timestamped_migrations
must be set to true.
425 426 427 |
# File 'lib/active_record.rb', line 425 def @validate_migration_timestamps end |
#verbose_query_logs ⇒ Object
:singleton-method: verbose_query_logs
Specifies if the methods calling database queries should be logged below their relevant queries. Defaults to false.
337 338 339 |
# File 'lib/active_record.rb', line 337 def verbose_query_logs @verbose_query_logs end |
#verify_foreign_keys_for_fixtures ⇒ Object
:singleton-method: verify_foreign_keys_for_fixtures If true, Rails will verify all foreign keys in the database after loading fixtures. An error will be raised if there are any foreign key violations, indicating incorrectly written fixtures. Supported by PostgreSQL and SQLite.
459 460 461 |
# File 'lib/active_record.rb', line 459 def verify_foreign_keys_for_fixtures @verify_foreign_keys_for_fixtures end |
#warn_on_records_fetched_greater_than ⇒ Object
:singleton-method: warn_on_records_fetched_greater_than Specify a threshold for the size of query result sets. If the number of records in the set exceeds the threshold, a warning is logged. This can be used to identify queries which load thousands of records and potentially cause memory bloat.
382 383 384 |
# File 'lib/active_record.rb', line 382 def warn_on_records_fetched_greater_than @warn_on_records_fetched_greater_than end |
#writing_role ⇒ Object
Returns the value of attribute writing_role.
265 266 267 |
# File 'lib/active_record.rb', line 265 def writing_role @writing_role end |
#yaml_column_permitted_classes ⇒ Object
:singleton-method: yaml_column_permitted_classes Application configurable array that provides additional permitted classes to Psych safe_load in the YAML Coder
498 499 500 |
# File 'lib/active_record.rb', line 498 def yaml_column_permitted_classes @yaml_column_permitted_classes end |
Class Method Details
.after_all_transactions_commit(&block) ⇒ Object
Registers a block to be called after all the current transactions have been committed.
If there is no currently open transaction, the block is called immediately.
If there are multiple nested transactions, the block is called after the outermost one has been committed,
If any of the currently open transactions is rolled back, the block is never called.
If multiple transactions are open across multiple databases, the block will be invoked if and once all of them have been committed. But note that nesting transactions across two distinct databases is a sharding anti-pattern that comes with a world of hurts.
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
# File 'lib/active_record.rb', line 572 def self.after_all_transactions_commit(&block) open_transactions = all_open_transactions if open_transactions.empty? yield elsif open_transactions.size == 1 open_transactions.first.after_commit(&block) else count = open_transactions.size callback = -> do count -= 1 block.call if count.zero? end open_transactions.each do |t| t.after_commit(&callback) end open_transactions = nil # rubocop:disable Lint/UselessAssignment avoid holding it in the closure end end |
.all_open_transactions ⇒ Object
:nodoc:
592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/active_record.rb', line 592 def self.all_open_transactions # :nodoc: open_transactions = [] Base.connection_handler.each_connection_pool do |pool| if active_connection = pool.active_connection if active_connection.current_transaction.open? && active_connection.current_transaction.joinable? open_transactions << active_connection.current_transaction end end end open_transactions end |
.allow_deprecated_singular_associations_name ⇒ Object
462 463 464 465 466 467 |
# File 'lib/active_record.rb', line 462 def self.allow_deprecated_singular_associations_name ActiveRecord.deprecator.warn <<-WARNING.squish `Rails.application.config.active_record.allow_deprecated_singular_associations_name` is deprecated and will be removed in Rails 8.0. WARNING end |
.allow_deprecated_singular_associations_name=(value) ⇒ Object
469 470 471 472 473 474 |
# File 'lib/active_record.rb', line 469 def self.allow_deprecated_singular_associations_name=(value) ActiveRecord.deprecator.warn <<-WARNING.squish `Rails.application.config.active_record.allow_deprecated_singular_associations_name` is deprecated and will be removed in Rails 8.0. WARNING end |
.commit_transaction_on_non_local_return ⇒ Object
362 363 364 365 366 367 |
# File 'lib/active_record.rb', line 362 def self.commit_transaction_on_non_local_return ActiveRecord.deprecator.warn <<-WARNING.squish `Rails.application.config.active_record.commit_transaction_on_non_local_return` is deprecated and will be removed in Rails 8.0. WARNING end |
.commit_transaction_on_non_local_return=(value) ⇒ Object
369 370 371 372 373 374 |
# File 'lib/active_record.rb', line 369 def self.commit_transaction_on_non_local_return=(value) ActiveRecord.deprecator.warn <<-WARNING.squish `Rails.application.config.active_record.commit_transaction_on_non_local_return` is deprecated and will be removed in Rails 8.0. WARNING end |
.db_warnings_action=(action) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/active_record.rb', line 235 def self.db_warnings_action=(action) @db_warnings_action = case action when :ignore nil when :log ->(warning) do = "[#{warning.class}] #{warning.}" += " (#{warning.code})" if warning.code ActiveRecord::Base.logger.warn() end when :raise ->(warning) { raise warning } when :report ->(warning) { Rails.error.report(warning, handled: true) } when Proc action else raise ArgumentError, "db_warnings_action must be one of :ignore, :log, :raise, :report, or a custom proc." end end |
.default_timezone=(default_timezone) ⇒ Object
Determines whether to use Time.utc (using :utc) or Time.local (using :local) when pulling dates and times from the database. This is set to :utc by default.
218 219 220 221 222 223 224 |
# File 'lib/active_record.rb', line 218 def self.default_timezone=(default_timezone) unless %i(local utc).include?(default_timezone) raise ArgumentError, "default_timezone must be either :utc (default) or :local." end @default_timezone = default_timezone end |
.deprecator ⇒ Object
:nodoc:
4 5 6 |
# File 'lib/active_record/deprecator.rb', line 4 def self.deprecator # :nodoc: @deprecator ||= ActiveSupport::Deprecation.new end |
.disconnect_all! ⇒ Object
Explicitly closes all database connections in all pools.
555 556 557 |
# File 'lib/active_record.rb', line 555 def self.disconnect_all! ConnectionAdapters::PoolConfig.disconnect_all! end |
.eager_load! ⇒ Object
544 545 546 547 548 549 550 551 552 |
# File 'lib/active_record.rb', line 544 def self.eager_load! super ActiveRecord::Locking.eager_load! ActiveRecord::Scoping.eager_load! ActiveRecord::Associations.eager_load! ActiveRecord::AttributeMethods.eager_load! ActiveRecord::ConnectionAdapters.eager_load! ActiveRecord::Encryption.eager_load! end |
.gem_version ⇒ Object
Returns the currently loaded version of Active Record as a Gem::Version
.
5 6 7 |
# File 'lib/active_record/gem_version.rb', line 5 def self.gem_version Gem::Version.new VERSION::STRING end |
.global_executor_concurrency ⇒ Object
:nodoc:
314 315 316 |
# File 'lib/active_record.rb', line 314 def self.global_executor_concurrency # :nodoc: @global_executor_concurrency ||= nil end |
.global_executor_concurrency=(global_executor_concurrency) ⇒ Object
Set the global_executor_concurrency
. This configuration value can only be used with the global thread pool async query executor.
306 307 308 309 310 311 312 |
# File 'lib/active_record.rb', line 306 def self.global_executor_concurrency=(global_executor_concurrency) if self.async_query_executor.nil? || self.async_query_executor == :multi_thread_pool raise ArgumentError, "`global_executor_concurrency` cannot be set when the executor is nil or set to `:multi_thread_pool`. For multiple thread pools, please set the concurrency in your database configuration." end @global_executor_concurrency = global_executor_concurrency end |
.global_thread_pool_async_query_executor ⇒ Object
:nodoc:
294 295 296 297 298 299 300 301 302 |
# File 'lib/active_record.rb', line 294 def self.global_thread_pool_async_query_executor # :nodoc: concurrency = global_executor_concurrency || 4 @global_thread_pool_async_query_executor ||= Concurrent::ThreadPoolExecutor.new( min_threads: 0, max_threads: concurrency, max_queue: concurrency * 4, fallback_policy: :caller_runs ) end |
.legacy_connection_handling=(_) ⇒ Object
271 272 273 274 275 276 277 |
# File 'lib/active_record.rb', line 271 def self.legacy_connection_handling=(_) raise ArgumentError, <<~MSG.squish The `legacy_connection_handling` setter was deprecated in 7.0 and removed in 7.1, but is still defined in your configuration. Please remove this call as it no longer has any effect." MSG end |
.marshalling_format_version ⇒ Object
508 509 510 |
# File 'lib/active_record.rb', line 508 def self.marshalling_format_version Marshalling.format_version end |
.marshalling_format_version=(value) ⇒ Object
512 513 514 |
# File 'lib/active_record.rb', line 512 def self.marshalling_format_version=(value) Marshalling.format_version = value end |
.permanent_connection_checkout=(value) ⇒ Object
Defines whether ActiveRecord::Base.connection
is allowed, deprecated, or entirely disallowed.
322 323 324 325 326 327 |
# File 'lib/active_record.rb', line 322 def self.permanent_connection_checkout=(value) unless [true, :deprecated, :disallowed].include?(value) raise ArgumentError, "permanent_connection_checkout must be one of: `true`, `:deprecated` or `:disallowed`" end @permanent_connection_checkout = value end |
.schema_cache_ignored_table?(table_name) ⇒ Boolean
Checks to see if the table_name
is ignored by checking against the schema_cache_ignored_tables
option.
ActiveRecord.schema_cache_ignored_table?(:developers)
205 206 207 208 209 |
# File 'lib/active_record.rb', line 205 def self.schema_cache_ignored_table?(table_name) ActiveRecord.schema_cache_ignored_tables.any? do |ignored| ignored === table_name end end |
.version ⇒ Object
Returns the currently loaded version of Active Record as a Gem::Version
.
7 8 9 |
# File 'lib/active_record/version.rb', line 7 def self.version gem_version end |