optional: true
.
# This can be used, for example, when conditionally validating the presence
# of the parent model:
#
# class Veterinarian < ActiveRecord::Base
# has_many :patients, inverse_of: :veterinarian
# accepts_nested_attributes_for :patients
# end
#
# class Patient < ActiveRecord::Base
# belongs_to :veterinarian, inverse_of: :patients, optional: true
# validates :veterinarian, presence: true, unless: -> { awaiting_intake }
# end
#
# Note that if you do not specify the +:inverse_of+ option, then
# Active Record will try to automatically guess the inverse association
# based on heuristics.
#
# For one-to-one nested associations, if you build the new (in-memory)
# child object yourself before assignment, then this module will not
# overwrite it, e.g.:
#
# class Member < ActiveRecord::Base
# has_one :avatar
# accepts_nested_attributes_for :avatar
#
# def avatar
# super || build_avatar(width: 200)
# end
# end
#
# member = Member.new
# member.avatar_attributes = {icon: 'sad'}
# member.avatar.width # => 200
#
# source://activerecord//lib/active_record/nested_attributes.rb#283
module ActiveRecord::NestedAttributes::ClassMethods
# Defines an attributes writer for the specified association(s).
#
# Supported options:
# [:allow_destroy]
# If true, destroys any members from the attributes hash with a
# _destroy key and a value that evaluates to +true+
# (e.g. 1, '1', true, or 'true'). This option is off by default.
# [:reject_if]
# Allows you to specify a Proc or a Symbol pointing to a method
# that checks whether a record should be built for a certain attribute
# hash. The hash is passed to the supplied Proc or the method
# and it should return either +true+ or +false+. When no +:reject_if+
# is specified, a record will be built for all attribute hashes that
# do not have a _destroy value that evaluates to true.
# Passing :all_blank instead of a Proc will create a proc
# that will reject a record where all the attributes are blank excluding
# any value for +_destroy+.
# [:limit]
# Allows you to specify the maximum number of associated records that
# can be processed with the nested attributes. Limit also can be specified
# as a Proc or a Symbol pointing to a method that should return a number.
# If the size of the nested attributes array exceeds the specified limit,
# NestedAttributes::TooManyRecords exception is raised. If omitted, any
# number of associations can be processed.
# Note that the +:limit+ option is only applicable to one-to-many
# associations.
# [:update_only]
# For a one-to-one association, this option allows you to specify how
# nested attributes are going to be used when an associated record already
# exists. In general, an existing record may either be updated with the
# new set of attribute values or be replaced by a wholly new record
# containing those values. By default the +:update_only+ option is +false+
# and the nested attributes are used to update the existing record only
# if they include the record's :id value. Otherwise a new
# record will be instantiated and used to replace the existing one.
# However if the +:update_only+ option is +true+, the nested attributes
# are used to update the record's attributes always, regardless of
# whether the :id is present. The option is ignored for collection
# associations.
#
# Examples:
# # creates avatar_attributes=
# accepts_nested_attributes_for :avatar, reject_if: proc { |attributes| attributes['name'].blank? }
# # creates avatar_attributes=
# accepts_nested_attributes_for :avatar, reject_if: :all_blank
# # creates avatar_attributes= and posts_attributes=
# accepts_nested_attributes_for :avatar, :posts, allow_destroy: true
#
# source://activerecord//lib/active_record/nested_attributes.rb#333
def accepts_nested_attributes_for(*attr_names); end
private
# Generates a writer method for this association. Serves as a point for
# accessing the objects in the association. For example, this method
# could generate the following:
#
# def pirate_attributes=(attributes)
# assign_nested_attributes_for_one_to_one_association(:pirate, attributes)
# end
#
# This redirects the attempts to write objects in an association through
# the helper methods defined below. Makes it seem like the nested
# associations are just regular associations.
#
# source://activerecord//lib/active_record/nested_attributes.rb#368
def generate_association_writer(association_name, type); end
end
# source://activerecord//lib/active_record/nested_attributes.rb#284
ActiveRecord::NestedAttributes::ClassMethods::REJECT_ALL_BLANK_PROC = T.let(T.unsafe(nil), Proc)
# source://activerecord//lib/active_record/nested_attributes.rb#9
class ActiveRecord::NestedAttributes::TooManyRecords < ::ActiveRecord::ActiveRecordError; end
# Attribute hash keys that should not be assigned as normal attributes.
# These hash keys are nested attributes implementation details.
#
# source://activerecord//lib/active_record/nested_attributes.rb#390
ActiveRecord::NestedAttributes::UNASSIGNABLE_KEYS = T.let(T.unsafe(nil), Array)
# Raised when a given database does not exist.
#
# source://activerecord//lib/active_record/errors.rb#238
class ActiveRecord::NoDatabaseError < ::ActiveRecord::StatementInvalid
include ::ActiveSupport::ActionableError
extend ::ActiveSupport::ActionableError::ClassMethods
# @return [NoDatabaseError] a new instance of NoDatabaseError
#
# source://activerecord//lib/active_record/errors.rb#245
def initialize(message = T.unsafe(nil)); end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions; end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions=(_arg0); end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions?; end
class << self
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions; end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions=(value); end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions?; end
# source://activerecord//lib/active_record/errors.rb#250
def db_error(db_name); end
end
end
# source://activerecord//lib/active_record/migration.rb#177
class ActiveRecord::NoEnvironmentInSchemaError < ::ActiveRecord::MigrationError
# @return [NoEnvironmentInSchemaError] a new instance of NoEnvironmentInSchemaError
#
# source://activerecord//lib/active_record/migration.rb#178
def initialize; end
end
# = Active Record No Touching
#
# source://activerecord//lib/active_record/no_touching.rb#5
module ActiveRecord::NoTouching
extend ::ActiveSupport::Concern
mixes_in_class_methods ::ActiveRecord::NoTouching::ClassMethods
# Returns +true+ if the class has +no_touching+ set, +false+ otherwise.
#
# Project.no_touching do
# Project.first.no_touching? # true
# Message.first.no_touching? # false
# end
#
# @return [Boolean]
#
# source://activerecord//lib/active_record/no_touching.rb#53
def no_touching?; end
# source://activerecord//lib/active_record/no_touching.rb#61
def touch(*_arg0, **_arg1); end
# source://activerecord//lib/active_record/no_touching.rb#57
def touch_later(*_arg0); end
class << self
# @return [Boolean]
#
# source://activerecord//lib/active_record/no_touching.rb#36
def applied_to?(klass); end
# source://activerecord//lib/active_record/no_touching.rb#29
def apply_to(klass); end
private
# source://activerecord//lib/active_record/no_touching.rb#41
def klasses; end
end
end
# source://activerecord//lib/active_record/no_touching.rb#8
module ActiveRecord::NoTouching::ClassMethods
# Lets you selectively disable calls to +touch+ for the
# duration of a block.
#
# ==== Examples
# ActiveRecord::Base.no_touching do
# Project.first.touch # does nothing
# Message.first.touch # does nothing
# end
#
# Project.no_touching do
# Project.first.touch # does nothing
# Message.first.touch # works, but does not touch the associated project
# end
#
# source://activerecord//lib/active_record/no_touching.rb#23
def no_touching(&block); end
end
# Raised when a record cannot be inserted or updated because it would violate a not null constraint.
#
# source://activerecord//lib/active_record/errors.rb#216
class ActiveRecord::NotNullViolation < ::ActiveRecord::StatementInvalid; end
# source://activerecord//lib/active_record/null_relation.rb#4
module ActiveRecord::NullRelation
# @return [Boolean]
#
# source://activerecord//lib/active_record/null_relation.rb#29
def any?; end
# source://activerecord//lib/active_record/null_relation.rb#41
def calculate(operation, _column_name); end
# source://activerecord//lib/active_record/null_relation.rb#17
def delete(_id_or_array); end
# source://activerecord//lib/active_record/null_relation.rb#9
def delete_all; end
# @return [Boolean]
#
# source://activerecord//lib/active_record/null_relation.rb#21
def empty?; end
# @return [Boolean]
#
# source://activerecord//lib/active_record/null_relation.rb#50
def exists?(_conditions = T.unsafe(nil)); end
# @return [Boolean]
#
# source://activerecord//lib/active_record/null_relation.rb#37
def many?; end
# @return [Boolean]
#
# source://activerecord//lib/active_record/null_relation.rb#25
def none?; end
# @return [Boolean]
#
# source://activerecord//lib/active_record/null_relation.rb#33
def one?; end
# source://activerecord//lib/active_record/null_relation.rb#54
def or(other); end
# source://activerecord//lib/active_record/null_relation.rb#5
def pluck(*column_names); end
# source://activerecord//lib/active_record/null_relation.rb#13
def update_all(_updates); end
private
# source://activerecord//lib/active_record/null_relation.rb#59
def exec_main_query(async: T.unsafe(nil)); end
end
# source://activerecord//lib/active_record/migration.rb#133
class ActiveRecord::PendingMigrationError < ::ActiveRecord::MigrationError
include ::ActiveSupport::ActionableError
extend ::ActiveSupport::ActionableError::ClassMethods
# @return [PendingMigrationError] a new instance of PendingMigrationError
#
# source://activerecord//lib/active_record/migration.rb#146
def initialize(message = T.unsafe(nil)); end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions; end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions=(_arg0); end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions?; end
private
# source://activerecord//lib/active_record/migration.rb#151
def detailed_migration_message; end
class << self
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions; end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions=(value); end
# source://activesupport/7.0.5/lib/active_support/actionable_error.rb#15
def _actions?; end
end
end
# = Active Record \Persistence
#
# source://activerecord//lib/active_record/persistence.rb#7
module ActiveRecord::Persistence
extend ::ActiveSupport::Concern
mixes_in_class_methods ::ActiveRecord::Persistence::ClassMethods
# Returns an instance of the specified +klass+ with the attributes of the
# current record. This is mostly useful in relation to single table
# inheritance (STI) structures where you want a subclass to appear as the
# superclass. This can be used along with record identification in
# Action Pack to allow, say, Client < Company to do something
# like render partial: @client.becomes(Company) to render that
# instance using the companies/company partial instead of clients/client.
#
# Note: The new instance will share a link to the same attributes as the original class.
# Therefore the STI column value will still be the same.
# Any change to the attributes on either instance will affect both instances.
# If you want to change the STI column as well, use #becomes! instead.
#
# source://activerecord//lib/active_record/persistence.rb#711
def becomes(klass); end
# Wrapper around #becomes that also changes the instance's STI column value.
# This is especially useful if you want to persist the changed class in your
# database.
#
# Note: The old instance's STI column value will be changed too, as both objects
# share the same set of attributes.
#
# source://activerecord//lib/active_record/persistence.rb#731
def becomes!(klass); end
# Initializes +attribute+ to zero if +nil+ and subtracts the value passed as +by+ (default is 1).
# The decrement is performed directly on the underlying attribute, no setter is invoked.
# Only makes sense for number-based attributes. Returns +self+.
#
# source://activerecord//lib/active_record/persistence.rb#856
def decrement(attribute, by = T.unsafe(nil)); end
# Wrapper around #decrement that writes the update to the database.
# Only +attribute+ is updated; the record itself is not saved.
# This means that any other modified attributes will still be dirty.
# Validations and callbacks are skipped. Supports the +touch+ option from
# +update_counters+, see that for more.
# Returns +self+.
#
# source://activerecord//lib/active_record/persistence.rb#866
def decrement!(attribute, by = T.unsafe(nil), touch: T.unsafe(nil)); end
# Deletes the record in the database and freezes this instance to
# reflect that no changes should be made (since they can't be
# persisted). Returns the frozen instance.
#
# The row is simply removed with an SQL +DELETE+ statement on the
# record's primary key, and no callbacks are executed.
#
# Note that this will also delete records marked as {#readonly?}[rdoc-ref:Core#readonly?].
#
# To enforce the object's +before_destroy+ and +after_destroy+
# callbacks or any :dependent association
# options, use #destroy.
#
# source://activerecord//lib/active_record/persistence.rb#663
def delete; end
# Deletes the record in the database and freezes this instance to reflect
# that no changes should be made (since they can't be persisted).
#
# There's a series of callbacks associated with #destroy. If the
# before_destroy callback throws +:abort+ the action is cancelled
# and #destroy returns +false+.
# See ActiveRecord::Callbacks for further details.
#
# source://activerecord//lib/active_record/persistence.rb#676
def destroy; end
# Deletes the record in the database and freezes this instance to reflect
# that no changes should be made (since they can't be persisted).
#
# There's a series of callbacks associated with #destroy!. If the
# before_destroy callback throws +:abort+ the action is cancelled
# and #destroy! raises ActiveRecord::RecordNotDestroyed.
# See ActiveRecord::Callbacks for further details.
#
# source://activerecord//lib/active_record/persistence.rb#695
def destroy!; end
# Returns true if this object has been destroyed, otherwise returns false.
#
# @return [Boolean]
#
# source://activerecord//lib/active_record/persistence.rb#579
def destroyed?; end
# Initializes +attribute+ to zero if +nil+ and adds the value passed as +by+ (default is 1).
# The increment is performed directly on the underlying attribute, no setter is invoked.
# Only makes sense for number-based attributes. Returns +self+.
#
# source://activerecord//lib/active_record/persistence.rb#833
def increment(attribute, by = T.unsafe(nil)); end
# Wrapper around #increment that writes the update to the database.
# Only +attribute+ is updated; the record itself is not saved.
# This means that any other modified attributes will still be dirty.
# Validations and callbacks are skipped. Supports the +touch+ option from
# +update_counters+, see that for more.
# Returns +self+.
#
# source://activerecord//lib/active_record/persistence.rb#845
def increment!(attribute, by = T.unsafe(nil), touch: T.unsafe(nil)); end
# Returns true if this object hasn't been saved yet -- that is, a record
# for the object doesn't exist in the database yet; otherwise, returns false.
#
# @return [Boolean]
#
# source://activerecord//lib/active_record/persistence.rb#562
def new_record?; end
# Returns true if the record is persisted, i.e. it's not a new record and it was
# not destroyed, otherwise returns false.
#
# @return [Boolean]
#
# source://activerecord//lib/active_record/persistence.rb#585
def persisted?; end
# Returns true if this object was just created -- that is, prior to the last
# save, the object didn't exist in the database and new_record? would have
# returned true.
#
# @return [Boolean]
#
# source://activerecord//lib/active_record/persistence.rb#569
def previously_new_record?; end
# Returns true if this object was previously persisted but now it has been deleted.
#
# @return [Boolean]
#
# source://activerecord//lib/active_record/persistence.rb#574
def previously_persisted?; end
# Reloads the record from the database.
#
# This method finds the record by its primary key (which could be assigned
# manually) and modifies the receiver in-place:
#
# account = Account.new
# # => #update_columns(name => value)
.
#
# source://activerecord//lib/active_record/persistence.rb#785
def update_column(name, value); end
# Updates the attributes directly in the database issuing an UPDATE SQL
# statement and sets them in the receiver:
#
# user.update_columns(last_request_at: Time.current)
#
# This is the fastest way to update attributes because it goes straight to
# the database, but take into account that in consequence the regular update
# procedures are totally bypassed. In particular:
#
# * \Validations are skipped.
# * \Callbacks are skipped.
# * +updated_at+/+updated_on+ are not updated.
# * However, attributes are serialized with the same rules as ActiveRecord::Relation#update_all
#
# This method raises an ActiveRecord::ActiveRecordError when called on new
# objects, or when at least one of the attributes is marked as readonly.
#
# @raise [ActiveRecordError]
#
# source://activerecord//lib/active_record/persistence.rb#805
def update_columns(attributes); end
private
# Creates a record with values matching those of the instance attributes
# and returns its id.
#
# @yield [_self]
# @yieldparam _self [ActiveRecord::Persistence] the object that the method was called on
#
# source://activerecord//lib/active_record/persistence.rb#1093
def _create_record(attribute_names = T.unsafe(nil)); end
# source://activerecord//lib/active_record/persistence.rb#1043
def _delete_row; end
# source://activerecord//lib/active_record/persistence.rb#1018
def _find_record(options); end
# source://activerecord//lib/active_record/persistence.rb#1031
def _primary_key_constraints_hash; end
# @raise [ReadOnlyRecord]
#
# source://activerecord//lib/active_record/persistence.rb#1122
def _raise_readonly_record_error; end
# source://activerecord//lib/active_record/persistence.rb#1114
def _raise_record_not_destroyed; end
# @raise [ActiveRecordError]
#
# source://activerecord//lib/active_record/persistence.rb#1126
def _raise_record_not_touched_error; end
# source://activerecord//lib/active_record/persistence.rb#1047
def _touch_row(attribute_names, time); end
# Updates the associated record with values matching those of the instance attributes.
# Returns the number of affected rows.
#
# @yield [_self]
# @yieldparam _self [ActiveRecord::Persistence] the object that the method was called on
#
# source://activerecord//lib/active_record/persistence.rb#1073
def _update_record(attribute_names = T.unsafe(nil)); end
# source://activerecord//lib/active_record/persistence.rb#1057
def _update_row(attribute_names, attempted_action = T.unsafe(nil)); end
# @return [Boolean]
#
# source://activerecord//lib/active_record/persistence.rb#1026
def apply_scoping?(options); end
# The name of the method used to touch a +belongs_to+ association when the
# +:touch+ option is used.
#
# source://activerecord//lib/active_record/persistence.rb#1135
def belongs_to_touch_method; end
# source://activerecord//lib/active_record/persistence.rb#1064
def create_or_update(**_arg0, &block); end
# A hook to be overridden by association modules.
#
# source://activerecord//lib/active_record/persistence.rb#1036
def destroy_associations; end
# source://activerecord//lib/active_record/persistence.rb#1039
def destroy_row; end
# source://activerecord//lib/active_record/persistence.rb#1012
def strict_loaded_associations; end
# @raise [ActiveRecordError]
#
# source://activerecord//lib/active_record/persistence.rb#1110
def verify_readonly_attribute(name); end
end
# source://activerecord//lib/active_record/persistence.rb#10
module ActiveRecord::Persistence::ClassMethods
# source://activerecord//lib/active_record/persistence.rb#516
def _delete_record(constraints); end
# source://activerecord//lib/active_record/persistence.rb#477
def _insert_record(values); end
# source://activerecord//lib/active_record/persistence.rb#499
def _update_record(values, constraints); end
# Creates an object (or multiple objects) and saves it to the database, if validations pass.
# The resulting object is returned whether the object was saved successfully to the database or not.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes. These Hashes describe the
# attributes on the objects that are to be created.
#
# ==== Examples
# # Create a single new object
# User.create(first_name: 'Jamie')
#
# # Create an Array of new objects
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
#
# # Create a single object and pass it into a block to set other attributes.
# User.create(first_name: 'Jamie') do |u|
# u.is_admin = false
# end
#
# # Creating an Array of new objects using a block, where the block is executed for each object:
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
# u.is_admin = false
# end
#
# source://activerecord//lib/active_record/persistence.rb#33
def create(attributes = T.unsafe(nil), &block); end
# Creates an object (or multiple objects) and saves it to the database,
# if validations pass. Raises a RecordInvalid error if validations fail,
# unlike Base#create.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes.
# These describe which attributes to be created on the object, or
# multiple objects when given an Array of Hashes.
#
# source://activerecord//lib/active_record/persistence.rb#50
def create!(attributes = T.unsafe(nil), &block); end
# Deletes the row with a primary key matching the +id+ argument, using an
# SQL +DELETE+ statement, and returns the number of rows deleted. Active
# Record objects are not instantiated, so the object's callbacks are not
# executed, including any :dependent association options.
#
# You can delete multiple rows at once by passing an Array of ids.
#
# Note: Although it is often much faster than the alternative, #destroy,
# skipping callbacks might bypass business logic in your application
# that ensures referential integrity or performs other essential jobs.
#
# ==== Examples
#
# # Delete a single row
# Todo.delete(1)
#
# # Delete multiple rows
# Todo.delete([2,3,4])
#
# source://activerecord//lib/active_record/persistence.rb#473
def delete(id_or_array); end
# Destroy an object (or multiple objects) that has the given id. The object is instantiated first,
# therefore all callbacks and filters are fired off before the object is deleted. This method is
# less efficient than #delete but allows cleanup methods and other actions to be run.
#
# This essentially finds the object (or multiple objects) with the given id, creates a new object
# from the attributes, and then calls destroy on it.
#
# ==== Parameters
#
# * +id+ - This should be the id or an array of ids to be destroyed.
#
# ==== Examples
#
# # Destroy a single object
# Todo.destroy(1)
#
# # Destroy multiple objects
# todos = [1,2,3]
# Todo.destroy(todos)
#
# source://activerecord//lib/active_record/persistence.rb#447
def destroy(id); end
# Inserts a single record into the database in a single SQL INSERT
# statement. It does not instantiate any models nor does it trigger
# Active Record callbacks or validations. Though passed values
# go through Active Record's type casting and serialization.
#
# See #insert_all for documentation.
#
# source://activerecord//lib/active_record/persistence.rb#66
def insert(attributes, returning: T.unsafe(nil), unique_by: T.unsafe(nil), record_timestamps: T.unsafe(nil)); end
# Inserts a single record into the database in a single SQL INSERT
# statement. It does not instantiate any models nor does it trigger
# Active Record callbacks or validations. Though passed values
# go through Active Record's type casting and serialization.
#
# See #insert_all! for more.
#
# source://activerecord//lib/active_record/persistence.rb#155
def insert!(attributes, returning: T.unsafe(nil), record_timestamps: T.unsafe(nil)); end
# Inserts multiple records into the database in a single SQL INSERT
# statement. It does not instantiate any models nor does it trigger
# Active Record callbacks or validations. Though passed values
# go through Active Record's type casting and serialization.
#
# The +attributes+ parameter is an Array of Hashes. Every Hash determines
# the attributes for a single row and must have the same keys.
#
# Rows are considered to be unique by every unique index on the table. Any
# duplicate rows are skipped.
# Override with :unique_by (see below).
#
# Returns an ActiveRecord::Result with its contents based on
# :returning (see below).
#
# ==== Options
#
# [:returning]
# (PostgreSQL only) An array of attributes to return for all successfully
# inserted records, which by default is the primary key.
# Pass returning: %w[ id name ] for both id and name
# or returning: false to omit the underlying RETURNING SQL
# clause entirely.
#
# You can also pass an SQL string if you need more control on the return values
# (for example, returning: "id, name as new_name").
#
# [:unique_by]
# (PostgreSQL and SQLite only) By default rows are considered to be unique
# by every unique index on the table. Any duplicate rows are skipped.
#
# To skip rows according to just one unique index pass :unique_by.
#
# Consider a Book model where no duplicate ISBNs make sense, but if any
# row has an existing id, or is not unique by another unique index,
# ActiveRecord::RecordNotUnique is raised.
#
# Unique indexes can be identified by columns or name:
#
# unique_by: :isbn
# unique_by: %i[ author_id name ]
# unique_by: :index_books_on_isbn
#
# [:record_timestamps]
# By default, automatic setting of timestamp columns is controlled by
# the model's record_timestamps config, matching typical
# behavior.
#
# To override this and force automatic setting of timestamp columns one
# way or the other, pass :record_timestamps:
#
# record_timestamps: true # Always set timestamps automatically
# record_timestamps: false # Never set timestamps automatically
#
# Because it relies on the index information from the database
# :unique_by is recommended to be paired with
# Active Record's schema_cache.
#
# ==== Example
#
# # Insert records and skip inserting any duplicates.
# # Here "Eloquent Ruby" is skipped because its id is not unique.
#
# Book.insert_all([
# { id: 1, title: "Rework", author: "David" },
# { id: 1, title: "Eloquent Ruby", author: "Russ" }
# ])
#
# # insert_all works on chained scopes, and you can use create_with
# # to set default attributes for all inserted records.
#
# author.books.create_with(created_at: Time.now).insert_all([
# { id: 1, title: "Rework" },
# { id: 2, title: "Eloquent Ruby" }
# ])
#
# source://activerecord//lib/active_record/persistence.rb#145
def insert_all(attributes, returning: T.unsafe(nil), unique_by: T.unsafe(nil), record_timestamps: T.unsafe(nil)); end
# Inserts multiple records into the database in a single SQL INSERT
# statement. It does not instantiate any models nor does it trigger
# Active Record callbacks or validations. Though passed values
# go through Active Record's type casting and serialization.
#
# The +attributes+ parameter is an Array of Hashes. Every Hash determines
# the attributes for a single row and must have the same keys.
#
# Raises ActiveRecord::RecordNotUnique if any rows violate a
# unique index on the table. In that case, no rows are inserted.
#
# To skip duplicate rows, see #insert_all. To replace them, see #upsert_all.
#
# Returns an ActiveRecord::Result with its contents based on
# :returning (see below).
#
# ==== Options
#
# [:returning]
# (PostgreSQL only) An array of attributes to return for all successfully
# inserted records, which by default is the primary key.
# Pass returning: %w[ id name ] for both id and name
# or returning: false to omit the underlying RETURNING SQL
# clause entirely.
#
# You can also pass an SQL string if you need more control on the return values
# (for example, returning: "id, name as new_name").
#
# [:record_timestamps]
# By default, automatic setting of timestamp columns is controlled by
# the model's record_timestamps config, matching typical
# behavior.
#
# To override this and force automatic setting of timestamp columns one
# way or the other, pass :record_timestamps:
#
# record_timestamps: true # Always set timestamps automatically
# record_timestamps: false # Never set timestamps automatically
#
# ==== Examples
#
# # Insert multiple records
# Book.insert_all!([
# { title: "Rework", author: "David" },
# { title: "Eloquent Ruby", author: "Russ" }
# ])
#
# # Raises ActiveRecord::RecordNotUnique because "Eloquent Ruby"
# # does not have a unique id.
# Book.insert_all!([
# { id: 1, title: "Rework", author: "David" },
# { id: 1, title: "Eloquent Ruby", author: "Russ" }
# ])
#
# source://activerecord//lib/active_record/persistence.rb#212
def insert_all!(attributes, returning: T.unsafe(nil), record_timestamps: T.unsafe(nil)); end
# Given an attributes hash, +instantiate+ returns a new instance of
# the appropriate class. Accepts only keys as strings.
#
# For example, +Post.all+ may return Comments, Messages, and Emails
# by storing the record's subclass in a +type+ attribute. By calling
# +instantiate+ instead of +new+, finder methods ensure they get new
# instances of the appropriate class for each record.
#
# See ActiveRecord::Inheritance#discriminate_class_for_record to see
# how this "single-table" inheritance mapping is implemented.
#
# source://activerecord//lib/active_record/persistence.rb#346
def instantiate(attributes, column_types = T.unsafe(nil), &block); end
# Updates an object (or multiple objects) and saves it to the database, if validations pass.
# The resulting object is returned whether the object was saved successfully to the database or not.
#
# ==== Parameters
#
# * +id+ - This should be the id or an array of ids to be updated.
# Optional argument, defaults to all records in the relation.
# * +attributes+ - This should be a hash of attributes or an array of hashes.
#
# ==== Examples
#
# # Updates one record
# Person.update(15, user_name: "Samuel", group: "expert")
#
# # Updates multiple records
# people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } }
# Person.update(people.keys, people.values)
#
# # Updates multiple records from the result of a relation
# people = Person.where(group: "expert")
# people.update(group: "masters")
#
# Note: Updating a large number of records will run an UPDATE
# query for each record, which may cause a performance issue.
# When running callbacks is not needed for each record update,
# it is preferred to use {update_all}[rdoc-ref:Relation#update_all]
# for updating all records in a single query.
#
# source://activerecord//lib/active_record/persistence.rb#378
def update(id = T.unsafe(nil), attributes); end
# Updates the object (or multiple objects) just like #update but calls #update! instead
# of +update+, so an exception is raised if the record is invalid and saving will fail.
#
# source://activerecord//lib/active_record/persistence.rb#404
def update!(id = T.unsafe(nil), attributes); end
# Updates or inserts (upserts) a single record into the database in a
# single SQL INSERT statement. It does not instantiate any models nor does
# it trigger Active Record callbacks or validations. Though passed values
# go through Active Record's type casting and serialization.
#
# See #upsert_all for documentation.
#
# source://activerecord//lib/active_record/persistence.rb#222
def upsert(attributes, on_duplicate: T.unsafe(nil), returning: T.unsafe(nil), unique_by: T.unsafe(nil), record_timestamps: T.unsafe(nil)); end
# Updates or inserts (upserts) multiple records into the database in a
# single SQL INSERT statement. It does not instantiate any models nor does
# it trigger Active Record callbacks or validations. Though passed values
# go through Active Record's type casting and serialization.
#
# The +attributes+ parameter is an Array of Hashes. Every Hash determines
# the attributes for a single row and must have the same keys.
#
# Returns an ActiveRecord::Result with its contents based on
# :returning (see below).
#
# By default, +upsert_all+ will update all the columns that can be updated when
# there is a conflict. These are all the columns except primary keys, read-only
# columns, and columns covered by the optional +unique_by+.
#
# ==== Options
#
# [:returning]
# (PostgreSQL only) An array of attributes to return for all successfully
# inserted records, which by default is the primary key.
# Pass returning: %w[ id name ] for both id and name
# or returning: false to omit the underlying RETURNING SQL
# clause entirely.
#
# You can also pass an SQL string if you need more control on the return values
# (for example, returning: "id, name as new_name").
#
# [:unique_by]
# (PostgreSQL and SQLite only) By default rows are considered to be unique
# by every unique index on the table. Any duplicate rows are skipped.
#
# To skip rows according to just one unique index pass :unique_by.
#
# Consider a Book model where no duplicate ISBNs make sense, but if any
# row has an existing id, or is not unique by another unique index,
# ActiveRecord::RecordNotUnique is raised.
#
# Unique indexes can be identified by columns or name:
#
# unique_by: :isbn
# unique_by: %i[ author_id name ]
# unique_by: :index_books_on_isbn
#
# Because it relies on the index information from the database
# :unique_by is recommended to be paired with
# Active Record's schema_cache.
#
# [:on_duplicate]
# Configure the SQL update sentence that will be used in case of conflict.
#
# NOTE: If you use this option you must provide all the columns you want to update
# by yourself.
#
# Example:
#
# Commodity.upsert_all(
# [
# { id: 2, name: "Copper", price: 4.84 },
# { id: 4, name: "Gold", price: 1380.87 },
# { id: 6, name: "Aluminium", price: 0.35 }
# ],
# on_duplicate: Arel.sql("price = GREATEST(commodities.price, EXCLUDED.price)")
# )
#
# See the related +:update_only+ option. Both options can't be used at the same time.
#
# [:update_only]
# Provide a list of column names that will be updated in case of conflict. If not provided,
# +upsert_all+ will update all the columns that can be updated. These are all the columns
# except primary keys, read-only columns, and columns covered by the optional +unique_by+
#
# Example:
#
# Commodity.upsert_all(
# [
# { id: 2, name: "Copper", price: 4.84 },
# { id: 4, name: "Gold", price: 1380.87 },
# { id: 6, name: "Aluminium", price: 0.35 }
# ],
# update_only: [:price] # Only prices will be updated
# )
#
# See the related +:on_duplicate+ option. Both options can't be used at the same time.
#
# [:record_timestamps]
# By default, automatic setting of timestamp columns is controlled by
# the model's record_timestamps config, matching typical
# behavior.
#
# To override this and force automatic setting of timestamp columns one
# way or the other, pass :record_timestamps:
#
# record_timestamps: true # Always set timestamps automatically
# record_timestamps: false # Never set timestamps automatically
#
# ==== Examples
#
# # Inserts multiple records, performing an upsert when records have duplicate ISBNs.
# # Here "Eloquent Ruby" overwrites "Rework" because its ISBN is duplicate.
#
# Book.upsert_all([
# { title: "Rework", author: "David", isbn: "1" },
# { title: "Eloquent Ruby", author: "Russ", isbn: "1" }
# ], unique_by: :isbn)
#
# Book.find_by(isbn: "1").title # => "Eloquent Ruby"
#
# source://activerecord//lib/active_record/persistence.rb#332
def upsert_all(attributes, on_duplicate: T.unsafe(nil), update_only: T.unsafe(nil), returning: T.unsafe(nil), unique_by: T.unsafe(nil), record_timestamps: T.unsafe(nil)); end
private
# Called by +_update_record+ and +_delete_record+
# to build `where` clause from default scopes.
# Skips empty scopes.
#
# source://activerecord//lib/active_record/persistence.rb#552
def build_default_constraint; end
# Called by +instantiate+ to decide which class to use for a new
# record instance.
#
# See +ActiveRecord::Inheritance#discriminate_class_for_record+ for
# the single-table inheritance discriminator.
#
# source://activerecord//lib/active_record/persistence.rb#545
def discriminate_class_for_record(record); end
# Given a class, an attributes hash, +instantiate_instance_of+ returns a
# new instance of the class. Accepts only keys as strings.
#
# source://activerecord//lib/active_record/persistence.rb#535
def instantiate_instance_of(klass, attributes, column_types = T.unsafe(nil), &block); end
end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#4
class ActiveRecord::PredicateBuilder
# @return [PredicateBuilder] a new instance of PredicateBuilder
#
# source://activerecord//lib/active_record/relation/predicate_builder.rb#12
def initialize(table); end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#53
def [](attr_name, value, operator = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#57
def build(attribute, value, operator = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#67
def build_bind_attribute(column_name, value); end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#23
def build_from_hash(attributes, &block); end
# Define how a class is converted to Arel nodes when passed to +where+.
# The handler can be any object that responds to +call+, and will be used
# for any value that +===+ the class given. For example:
#
# MyCustomDateRange = Struct.new(:start, :end)
# handler = proc do |column, range|
# Arel::Nodes::Between.new(column,
# Arel::Nodes::And.new([range.start, range.end])
# )
# end
# ActiveRecord::PredicateBuilder.new("users").register_handler(MyCustomDateRange, handler)
#
# source://activerecord//lib/active_record/relation/predicate_builder.rb#49
def register_handler(klass, handler); end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#72
def resolve_arel_attribute(table_name, column_name, &block); end
protected
# source://activerecord//lib/active_record/relation/predicate_builder.rb#77
def expand_from_hash(attributes, &block); end
private
# source://activerecord//lib/active_record/relation/predicate_builder.rb#145
def convert_dot_notation_to_hash(attributes); end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#135
def grouping_queries(queries); end
# source://activerecord//lib/active_record/relation/predicate_builder.rb#161
def handler_for(object); end
# Returns the value of attribute table.
#
# source://activerecord//lib/active_record/relation/predicate_builder.rb#133
def table; end
class << self
# source://activerecord//lib/active_record/relation/predicate_builder.rb#28
def references(attributes); end
end
end
# source://activerecord//lib/active_record/relation/predicate_builder/array_handler.rb#7
class ActiveRecord::PredicateBuilder::ArrayHandler
# @return [ArrayHandler] a new instance of ArrayHandler
#
# source://activerecord//lib/active_record/relation/predicate_builder/array_handler.rb#8
def initialize(predicate_builder); end
# source://activerecord//lib/active_record/relation/predicate_builder/array_handler.rb#12
def call(attribute, value); end
private
# Returns the value of attribute predicate_builder.
#
# source://activerecord//lib/active_record/relation/predicate_builder/array_handler.rb#39
def predicate_builder; end
end
# source://activerecord//lib/active_record/relation/predicate_builder/array_handler.rb#41
module ActiveRecord::PredicateBuilder::ArrayHandler::NullPredicate
class << self
# source://activerecord//lib/active_record/relation/predicate_builder/array_handler.rb#42
def or(other); end
end
end
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#5
class ActiveRecord::PredicateBuilder::AssociationQueryValue
# @return [AssociationQueryValue] a new instance of AssociationQueryValue
#
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#6
def initialize(associated_table, value); end
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#11
def queries; end
private
# Returns the value of attribute associated_table.
#
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#16
def associated_table; end
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#33
def convert_to_id(value); end
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#18
def ids; end
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#29
def primary_key; end
# Returns the value of attribute value.
#
# source://activerecord//lib/active_record/relation/predicate_builder/association_query_value.rb#16
def value; end
end
# source://activerecord//lib/active_record/relation/predicate_builder/basic_object_handler.rb#5
class ActiveRecord::PredicateBuilder::BasicObjectHandler
# @return [BasicObjectHandler] a new instance of BasicObjectHandler
#
# source://activerecord//lib/active_record/relation/predicate_builder/basic_object_handler.rb#6
def initialize(predicate_builder); end
# source://activerecord//lib/active_record/relation/predicate_builder/basic_object_handler.rb#10
def call(attribute, value); end
private
# Returns the value of attribute predicate_builder.
#
# source://activerecord//lib/active_record/relation/predicate_builder/basic_object_handler.rb#16
def predicate_builder; end
end
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#5
class ActiveRecord::PredicateBuilder::PolymorphicArrayValue
# @return [PolymorphicArrayValue] a new instance of PolymorphicArrayValue
#
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#6
def initialize(associated_table, values); end
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#11
def queries; end
private
# Returns the value of attribute associated_table.
#
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#23
def associated_table; end
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#45
def convert_to_id(value); end
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#36
def klass(value); end
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#32
def primary_key(value); end
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#25
def type_to_ids_mapping; end
# Returns the value of attribute values.
#
# source://activerecord//lib/active_record/relation/predicate_builder/polymorphic_array_value.rb#23
def values; end
end
# source://activerecord//lib/active_record/relation/predicate_builder/range_handler.rb#5
class ActiveRecord::PredicateBuilder::RangeHandler
# @return [RangeHandler] a new instance of RangeHandler
#
# source://activerecord//lib/active_record/relation/predicate_builder/range_handler.rb#8
def initialize(predicate_builder); end
# source://activerecord//lib/active_record/relation/predicate_builder/range_handler.rb#12
def call(attribute, value); end
private
# Returns the value of attribute predicate_builder.
#
# source://activerecord//lib/active_record/relation/predicate_builder/range_handler.rb#19
def predicate_builder; end
end
# source://activerecord//lib/active_record/relation/predicate_builder/range_handler.rb#6
class ActiveRecord::PredicateBuilder::RangeHandler::RangeWithBinds < ::Struct
# Returns the value of attribute begin
#
# @return [Object] the current value of begin
def begin; end
# Sets the attribute begin
#
# @param value [Object] the value to set the attribute begin to.
# @return [Object] the newly set value
def begin=(_); end
# Returns the value of attribute end
#
# @return [Object] the current value of end
def end; end
# Sets the attribute end
#
# @param value [Object] the value to set the attribute end to.
# @return [Object] the newly set value
def end=(_); end
# Returns the value of attribute exclude_end?
#
# @return [Object] the current value of exclude_end?
def exclude_end?; end
class << self
def [](*_arg0); end
def inspect; end
def keyword_init?; end
def members; end
def new(*_arg0); end
end
end
# source://activerecord//lib/active_record/relation/predicate_builder/relation_handler.rb#5
class ActiveRecord::PredicateBuilder::RelationHandler
# source://activerecord//lib/active_record/relation/predicate_builder/relation_handler.rb#6
def call(attribute, value); end
end
# Raised when PostgreSQL returns 'cached plan must not change result type' and
# we cannot retry gracefully (e.g. inside a transaction)
#
# source://activerecord//lib/active_record/errors.rb#271
class ActiveRecord::PreparedStatementCacheExpired < ::ActiveRecord::StatementInvalid; end
# Raised when the number of placeholders in an SQL fragment passed to
# {ActiveRecord::Base.where}[rdoc-ref:QueryMethods#where]
# does not match the number of values supplied.
#
# For example, when there are two placeholders with only one value supplied:
#
# Location.where("lat = ? AND lng = ?", 53.7362)
#
# source://activerecord//lib/active_record/errors.rb#234
class ActiveRecord::PreparedStatementInvalid < ::ActiveRecord::ActiveRecordError; end
# source://activerecord//lib/active_record/migration.rb#188
class ActiveRecord::ProtectedEnvironmentError < ::ActiveRecord::ActiveRecordError
# @return [ProtectedEnvironmentError] a new instance of ProtectedEnvironmentError
#
# source://activerecord//lib/active_record/migration.rb#189
def initialize(env = T.unsafe(nil)); end
end
# Superclass for errors that have been aborted (either by client or server).
#
# source://activerecord//lib/active_record/errors.rb#445
class ActiveRecord::QueryAborted < ::ActiveRecord::StatementInvalid; end
# = Active Record Query Cache
#
# source://activerecord//lib/active_record/query_cache.rb#5
class ActiveRecord::QueryCache
class << self
# source://activerecord//lib/active_record/query_cache.rb#42
def complete(pools); end
# source://activerecord//lib/active_record/query_cache.rb#58
def install_executor_hooks(executor = T.unsafe(nil)); end
# source://activerecord//lib/active_record/query_cache.rb#28
def run; end
end
end
# source://activerecord//lib/active_record/query_cache.rb#6
module ActiveRecord::QueryCache::ClassMethods
# Enable the query cache within the block if Active Record is configured.
# If it's not, it will execute the given block.
#
# source://activerecord//lib/active_record/query_cache.rb#9
def cache(&block); end
# Disable the query cache within the block if Active Record is configured.
# If it's not, it will execute the given block.
#
# source://activerecord//lib/active_record/query_cache.rb#19
def uncached(&block); end
end
# QueryCanceled will be raised when canceling statement due to user request.
#
# source://activerecord//lib/active_record/errors.rb#457
class ActiveRecord::QueryCanceled < ::ActiveRecord::QueryAborted; end
# = Active Record Query Logs
#
# Automatically tag SQL queries with runtime information.
#
# Default tags available for use:
#
# * +application+
# * +pid+
# * +socket+
# * +db_host+
# * +database+
#
# _Action Controller and Active Job tags are also defined when used in Rails:_
#
# * +controller+
# * +action+
# * +job+
#
# The tags used in a query can be configured directly:
#
# ActiveRecord::QueryLogs.tags = [ :application, :controller, :action, :job ]
#
# or via Rails configuration:
#
# config.active_record.query_log_tags = [ :application, :controller, :action, :job ]
#
# To add new comment tags, add a hash to the tags array containing the keys and values you
# want to add to the comment. Dynamic content can be created by setting a proc or lambda value in a hash,
# and can reference any value stored in the +context+ object.
#
# Escaping is performed on the string returned, however untrusted user input should not be used.
#
# Example:
#
# tags = [
# :application,
# {
# custom_tag: ->(context) { context[:controller]&.controller_name },
# custom_value: -> { Custom.value },
# }
# ]
# ActiveRecord::QueryLogs.tags = tags
#
# The QueryLogs +context+ can be manipulated via the +ActiveSupport::ExecutionContext.set+ method.
#
# Temporary updates limited to the execution of a block:
#
# ActiveSupport::ExecutionContext.set(foo: Bar.new) do
# posts = Post.all
# end
#
# Direct updates to a context value:
#
# ActiveSupport::ExecutionContext[:foo] = Bar.new
#
# Tag comments can be prepended to the query:
#
# ActiveRecord::QueryLogs.prepend_comment = true
#
# For applications where the content will not change during the lifetime of
# the request or job execution, the tags can be cached for reuse in every query:
#
# ActiveRecord::QueryLogs.cache_query_log_tags = true
#
# This option can be set during application configuration or in a Rails initializer:
#
# config.active_record.cache_query_log_tags = true
#
# source://activerecord//lib/active_record/query_logs.rb#73
module ActiveRecord::QueryLogs
class << self
# source://activerecord//lib/active_record/query_logs.rb#77
def cache_query_log_tags; end
# source://activerecord//lib/active_record/query_logs.rb#77
def cache_query_log_tags=(val); end
# source://activesupport/7.0.5/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb#48
def cached_comment; end
# source://activesupport/7.0.5/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb#92
def cached_comment=(obj); end
# source://activerecord//lib/active_record/query_logs.rb#81
def call(sql); end
# source://activerecord//lib/active_record/query_logs.rb#89
def clear_cache; end
# source://activerecord//lib/active_record/query_logs.rb#76
def prepend_comment; end
# source://activerecord//lib/active_record/query_logs.rb#76
def prepend_comment=(val); end
# source://activerecord//lib/active_record/query_logs.rb#74
def taggings; end
# source://activerecord//lib/active_record/query_logs.rb#74
def taggings=(val); end
# source://activerecord//lib/active_record/query_logs.rb#75
def tags; end
# source://activerecord//lib/active_record/query_logs.rb#75
def tags=(val); end
private
# Returns an SQL comment +String+ containing the query log tags.
# Sets and returns a cached comment if cache_query_log_tags is +true+.
#
# source://activerecord//lib/active_record/query_logs.rb#98
def comment; end
# source://activerecord//lib/active_record/query_logs.rb#113
def escape_sql_comment(content); end
# source://activerecord//lib/active_record/query_logs.rb#126
def tag_content; end
# source://activerecord//lib/active_record/query_logs.rb#106
def uncached_comment; end
end
end
# source://activerecord//lib/active_record/relation/query_methods.rb#10
module ActiveRecord::QueryMethods
include ::ActiveModel::ForbiddenAttributesProtection
# source://activerecord//lib/active_record/relation/query_methods.rb#317
def _select!(*fields); end
# Returns a new relation, which is the logical intersection of this relation and the one passed
# as an argument.
#
# The two relations must be structurally compatible: they must be scoping the same model, and
# they must differ only by #where (if no #group has been defined) or #having (if a #group is
# present).
#
# Post.where(id: [1, 2]).and(Post.where(id: [2, 3]))
# # SELECT `posts`.* FROM `posts` WHERE `posts`.`id` IN (1, 2) AND `posts`.`id` IN (2, 3)
#
# source://activerecord//lib/active_record/relation/query_methods.rb#845
def and(other); end
# source://activerecord//lib/active_record/relation/query_methods.rb#853
def and!(other); end
# Adds an SQL comment to queries generated from this relation. For example:
#
# User.annotate("selecting user names").select(:name)
# # SELECT "users"."name" FROM "users" /* selecting user names */
#
# User.annotate("selecting", "user", "names").select(:name)
# # SELECT "users"."name" FROM "users" /* selecting */ /* user */ /* names */
#
# The SQL block comment delimiters, "/*" and "*/", will be added automatically.
#
# Some escaping is performed, however untrusted user input should not be used.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1221
def annotate(*args); end
# Like #annotate, but modifies relation in place.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1227
def annotate!(*args); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def annotate_values; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def annotate_values=(value); end
# Returns the Arel object associated with the relation.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1282
def arel(aliases = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/query_methods.rb#1286
def construct_join_dependency(associations, join_type); end
# Sets attributes to be used when creating new records from a
# relation object.
#
# users = User.where(name: 'Oscar')
# users.new.name # => 'Oscar'
#
# users = users.create_with(name: 'DHH')
# users.new.name # => 'DHH'
#
# You can pass +nil+ to #create_with to reset attributes:
#
# users = users.create_with(nil)
# users.new.name # => 'Oscar'
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1038
def create_with(value); end
# source://activerecord//lib/active_record/relation/query_methods.rb#1042
def create_with!(value); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def create_with_value; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def create_with_value=(value); end
# Specifies whether the records should be unique or not. For example:
#
# User.select(:name)
# # Might return two records with the same name
#
# User.select(:name).distinct
# # Returns 1 record per distinct name
#
# User.select(:name).distinct.distinct(false)
# # You can also remove the uniqueness
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1102
def distinct(value = T.unsafe(nil)); end
# Like #distinct, but modifies relation in place.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1107
def distinct!(value = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def distinct_value; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def distinct_value=(value); end
# Forces eager loading by performing a LEFT OUTER JOIN on +args+:
#
# User.eager_load(:posts)
# # SELECT "users"."id" AS t0_r0, "users"."name" AS t0_r1, ...
# # FROM "users" LEFT OUTER JOIN "posts" ON "posts"."user_id" =
# # "users"."id"
#
# source://activerecord//lib/active_record/relation/query_methods.rb#207
def eager_load(*args); end
# source://activerecord//lib/active_record/relation/query_methods.rb#212
def eager_load!(*args); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def eager_load_values; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def eager_load_values=(value); end
# Excludes the specified record (or collection of records) from the resulting
# relation. For example:
#
# Post.excluding(post)
# # SELECT "posts".* FROM "posts" WHERE "posts"."id" != 1
#
# Post.excluding(post_one, post_two)
# # SELECT "posts".* FROM "posts" WHERE "posts"."id" NOT IN (1, 2)
#
# This can also be called on associations. As with the above example, either
# a single record of collection thereof may be specified:
#
# post = Post.find(1)
# comment = Comment.find(2)
# post.comments.excluding(comment)
# # SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = 1 AND "comments"."id" != 2
#
# This is short-hand for .where.not(id: post.id) and .where.not(id: [post_one.id, post_two.id]).
#
# An ArgumentError will be raised if either no records are
# specified, or if any of the records in the collection (if a collection
# is passed in) are not instances of the same model that the relation is
# scoping.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1263
def excluding(*records); end
# source://activerecord//lib/active_record/relation/query_methods.rb#1275
def excluding!(records); end
# Used to extend a scope with additional methods, either through
# a module or through a block provided.
#
# The object returned is a relation, which can be further extended.
#
# === Using a module
#
# module Pagination
# def page(number)
# # pagination code goes here
# end
# end
#
# scope = Model.all.extending(Pagination)
# scope.page(params[:page])
#
# You can also pass a list of modules:
#
# scope = Model.all.extending(Pagination, SomethingElse)
#
# === Using a block
#
# scope = Model.all.extending do
# def page(number)
# # pagination code goes here
# end
# end
# scope.page(params[:page])
#
# You can also use a block and a module list:
#
# scope = Model.all.extending(Pagination) do
# def per_page(number)
# # pagination code goes here
# end
# end
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1148
def extending(*modules, &block); end
# source://activerecord//lib/active_record/relation/query_methods.rb#1156
def extending!(*modules, &block); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def extending_values; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def extending_values=(value); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def extensions; end
# Extracts a named +association+ from the relation. The named association is first preloaded,
# then the individual association records are collected from the relation. Like so:
#
# account.memberships.extract_associated(:user)
# # => Returns collection of User records
#
# This is short-hand for:
#
# account.memberships.preload(:user).collect(&:user)
#
# source://activerecord//lib/active_record/relation/query_methods.rb#240
def extract_associated(association); end
# Specifies the table from which the records will be fetched. For example:
#
# Topic.select('title').from('posts')
# # SELECT title FROM posts
#
# Can accept other relation objects. For example:
#
# Topic.select('title').from(Topic.approved)
# # SELECT title FROM (SELECT * FROM topics WHERE approved = 't') subquery
#
# Passing a second argument (string or symbol), creates the alias for the SQL from clause. Otherwise the alias "subquery" is used:
#
# Topic.select('a.title').from(Topic.approved, :a)
# # SELECT a.title FROM (SELECT * FROM topics WHERE approved = 't') a
#
# It does not add multiple arguments to the SQL from clause. The last +from+ chained is the one used:
#
# Topic.select('title').from(Topic.approved).from(Topic.inactive)
# # SELECT title FROM (SELECT topics.* FROM topics WHERE topics.active = 'f') subquery
#
# For multiple arguments for the SQL from clause, you can pass a string with the exact elements in the SQL from list:
#
# color = "red"
# Color
# .from("colors c, JSONB_ARRAY_ELEMENTS(colored_things) AS colorvalues(colorvalue)")
# .where("colorvalue->>'color' = ?", color)
# .select("c.*").to_a
# # SELECT c.*
# # FROM colors c, JSONB_ARRAY_ELEMENTS(colored_things) AS colorvalues(colorvalue)
# # WHERE (colorvalue->>'color' = 'red')
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1083
def from(value, subquery_name = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/query_methods.rb#1087
def from!(value, subquery_name = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def from_clause; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def from_clause=(value); end
# Allows to specify a group attribute:
#
# User.group(:name)
# # SELECT "users".* FROM "users" GROUP BY name
#
# Returns an array with distinct records based on the +group+ attribute:
#
# User.select([:id, :name])
# # => [#ORDER BY
clause to a query.
#
# #order accepts arguments in one of several formats.
#
# === symbols
#
# The symbol represents the name of the column you want to order the results by.
#
# User.order(:name)
# # SELECT "users".* FROM "users" ORDER BY "users"."name" ASC
#
# By default, the order is ascending. If you want descending order, you can
# map the column name symbol to +:desc+.
#
# User.order(email: :desc)
# # SELECT "users".* FROM "users" ORDER BY "users"."email" DESC
#
# Multiple columns can be passed this way, and they will be applied in the order specified.
#
# User.order(:name, email: :desc)
# # SELECT "users".* FROM "users" ORDER BY "users"."name" ASC, "users"."email" DESC
#
# === strings
#
# Strings are passed directly to the database, allowing you to specify
# simple SQL expressions.
#
# This could be a source of SQL injection, so only strings composed of plain
# column names and simple function(column_name)
expressions
# with optional +ASC+/+DESC+ modifiers are allowed.
#
# User.order('name')
# # SELECT "users".* FROM "users" ORDER BY name
#
# User.order('name DESC')
# # SELECT "users".* FROM "users" ORDER BY name DESC
#
# User.order('name DESC, email')
# # SELECT "users".* FROM "users" ORDER BY name DESC, email
#
# === Arel
#
# If you need to pass in complicated expressions that you have verified
# are safe for the database, you can use Arel.
#
# User.order(Arel.sql('end_date - start_date'))
# # SELECT "users".* FROM "users" ORDER BY end_date - start_date
#
# Custom query syntax, like JSON columns for Postgres, is supported in this way.
#
# User.order(Arel.sql("payload->>'kind'"))
# # SELECT "users".* FROM "users" ORDER BY payload->>'kind'
#
# source://activerecord//lib/active_record/relation/query_methods.rb#425
def order(*args); end
# Same as #order but operates on relation in-place instead of copying.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#433
def order!(*args); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def order_values; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def order_values=(value); end
# Allows preloading of +args+, in the same way that #includes does:
#
# User.preload(:posts)
# # SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (1, 2, 3)
#
# source://activerecord//lib/active_record/relation/query_methods.rb#221
def preload(*args); end
# source://activerecord//lib/active_record/relation/query_methods.rb#226
def preload!(*args); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def preload_values; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def preload_values=(value); end
# Sets readonly attributes for the returned relation. If value is
# true (default), attempting to update a record will result in an error.
#
# users = User.readonly
# users.first.save
# => ActiveRecord::ReadOnlyRecord: User is marked as readonly
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1001
def readonly(value = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/query_methods.rb#1005
def readonly!(value = T.unsafe(nil)); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def readonly_value; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def readonly_value=(value); end
# Use to indicate that the given +table_names+ are referenced by an SQL string,
# and should therefore be JOINed in any query rather than loaded separately.
# This method only works in conjunction with #includes.
# See #includes for more details.
#
# User.includes(:posts).where("posts.name = 'foo'")
# # Doesn't JOIN the posts table, resulting in an error.
#
# User.includes(:posts).where("posts.name = 'foo'").references(:posts)
# # Query now knows the string references posts, so adds a JOIN
#
# source://activerecord//lib/active_record/relation/query_methods.rb#254
def references(*table_names); end
# source://activerecord//lib/active_record/relation/query_methods.rb#259
def references!(*table_names); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def references_values; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def references_values=(value); end
# Replaces any existing order defined on the relation with the specified order.
#
# User.order('email DESC').reorder('id ASC') # generated SQL has 'ORDER BY id ASC'
#
# Subsequent calls to order on the same relation will be appended. For example:
#
# User.order('email DESC').reorder('id ASC').order('name ASC')
#
# generates a query with 'ORDER BY id ASC, name ASC'.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#471
def reorder(*args); end
# Same as #reorder but operates on relation in-place instead of copying.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#479
def reorder!(*args); end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def reordering_value; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def reordering_value=(value); end
# Allows you to change a previously set select statement.
#
# Post.select(:title, :body)
# # SELECT `posts`.`title`, `posts`.`body` FROM `posts`
#
# Post.select(:title, :body).reselect(:created_at)
# # SELECT `posts`.`created_at` FROM `posts`
#
# This is short-hand for unscope(:select).select(fields).
# Note that we're unscoping the entire select statement.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#332
def reselect(*args); end
# Same as #reselect but operates on relation in-place instead of copying.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#338
def reselect!(*args); end
# Reverse the existing order clause on the relation.
#
# User.order('name ASC').reverse_order # generated SQL has 'ORDER BY name DESC'
#
# source://activerecord//lib/active_record/relation/query_methods.rb#1190
def reverse_order; end
# source://activerecord//lib/active_record/relation/query_methods.rb#1194
def reverse_order!; end
# source://activerecord//lib/active_record/relation/query_methods.rb#139
def reverse_order_value; end
# source://activerecord//lib/active_record/relation/query_methods.rb#143
def reverse_order_value=(value); end
# Allows you to change a previously set where condition for a given attribute, instead of appending to that condition.
#
# Post.where(trashed: true).where(trashed: false)
# # WHERE `trashed` = 1 AND `trashed` = 0
#
# Post.where(trashed: true).rewhere(trashed: false)
# # WHERE `trashed` = 0
#
# Post.where(active: true).where(trashed: true).rewhere(trashed: false)
# # WHERE `active` = 1 AND `trashed` = 0
#
# This is short-hand for unscope(where: conditions.keys).where(conditions).
# Note that unlike reorder, we're only unscoping the named conditions -- not the entire where statement.
#
# source://activerecord//lib/active_record/relation/query_methods.rb#773
def rewhere(conditions); end
# Works in two unique ways.
#
# First: takes a block so it can be used just like Array#select.
#
# Model.all.select { |m| m.field == value }
#
# This will build an array of objects from the database for the scope,
# converting them into an array and iterating through them using
# Array#select.
#
# Second: Modifies the SELECT statement for the query so that only certain
# fields are retrieved:
#
# Model.select(:field)
# # => [#