update_all

update_all(updates) Instance Public methods Updates all records with details given if they match a set of conditions supplied, limits and order can also be supplied. This method constructs a single SQL UPDATE statement and sends it straight to the database. It does not instantiate the involved models and it does not trigger Active Record callbacks or validations. Parameters updates - A string, array, or hash representing the SET part of an SQL statement. Examples # Update all cu

update

update(id, attributes) Instance Public methods 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. 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 mu

uniq_value

uniq_value() Instance Public methods uniq and uniq! are silently deprecated. uniq_value delegates to distinct_value to maintain backwards compatibility. Use distinct_value instead.

to_sql

to_sql() Instance Public methods Returns sql statement for the relation. User.where(name: 'Oscar').to_sql # => SELECT "users".* FROM "users" WHERE "users"."name" = 'Oscar'

to_a

to_a() Instance Public methods Converts relation objects to Array.

size

size() Instance Public methods Returns size of the records.

scoping

scoping() Instance Public methods Scope all queries to the current scope. Comment.where(post_id: 1).scoping do Comment.first end # => SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = 1 ORDER BY "comments"."id" ASC LIMIT 1 Please check unscoped if you want to remove all previous scopes (including the default_scope) during the execution of a block.

scope_for_create

scope_for_create() Instance Public methods

reset

reset() Instance Public methods

reload

reload() Instance Public methods Forces reloading of relation.