update_column

update_column(name, value) Instance Public methods Equivalent to update_columns(name => value).

update_columns

update_columns(attributes) Instance Public methods 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 a

cache

cache(&block) Instance Public methods Enable the query cache within the block if Active Record is configured. If it's not, it will execute the given block.

uncached

uncached(&block) Instance Public methods Disable the query cache within the block if Active Record is configured. If it's not, it will execute the given block.

new

new(app) Class Public methods

call

call(env) Instance Public methods

count_by_sql

count_by_sql(sql) Instance Public methods Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part. The use of this method should be restricted to complicated SQL queries that can't be executed using the ActiveRecord::Calculations class methods. Look into those before using this. Parameters sql - An SQL statement which should return a count query from the database, see the example below. Product.count_by_sql âSELECT COUNT(*) FROM sales s, cust

find_by_sql

find_by_sql(sql, binds = []) Instance Public methods Executes a custom SQL query against your database and returns all the results. The results will be returned as an array with columns requested encapsulated as attributes of the model you call this method from. If you call Product.find_by_sql then the results will be returned in a Product object with the attributes you specified in the SQL query. If you call a complicated SQL query which spans multiple tables the columns specified

new

new(scope) Class Public methods

not

not(opts, *rest) Instance Public methods Returns a new relation expressing WHERE + NOT condition according to the conditions in the arguments. not accepts conditions as a string, array, or hash. See where for more details on each format. User.where.not("name = 'Jon'") # SELECT * FROM users WHERE NOT (name = 'Jon') User.where.not(["name = ?", "Jon"]) # SELECT * FROM users WHERE NOT (name = 'Jon') User.where.not(name: "Jon") # SELECT * FROM users WHERE name != 'Jon' User.where.not