sanitize_sql_hash_for_conditions

sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name) Instance Protected methods Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause. { name: "foo'bar", group_id: 4 } # => "name='foo''bar' and group_id= 4" { status: nil, group_id: [1,2,3] } # => "status IS NULL and group_id IN (1,2,3)" { age: 13..18 } # => "age BETWEEN 13 AND 18" { 'other_records.id' => 7 } # => "`other_records`.`id` = 7" { other_records: {

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

new

new(*args, &block) Instance Public methods Determines if one of the attributes passed in is the inheritance column, and if the inheritance column is attr accessible, it initializes an instance of the given subclass instead of the base class.

assert_migration

assert_migration(relative, *contents, &block) Instance Public methods Asserts a given migration exists. You need to supply an absolute path or a path relative to the configured destination: assert_migration "db/migrate/create_products.rb" This method manipulates the given path and tries to find any migration which matches the migration name. For example, the call above is converted to: assert_file "db/migrate/003_create_products.rb" Consequently, #assert_migration accepts the

to_param

to_param() Instance Public methods

type_to_sql

type_to_sql(type, limit = nil, precision = nil, scale = nil) Instance Public methods Maps logical Rails types to MySQL-specific data types.

index_by

index_by() Instance Public methods Convert an enumerable to a hash. people.index_by(&:login) => { "nextangle" => <Person ...>, "chade-" => <Person ...>, ...} people.index_by { |person| "#{person.first_name} #{person.last_name}" } => { "Chade- Fowlersburg-e" => <Person ...>, "David Heinemeier Hansson" => <Person ...>, ...}

readonly

readonly(value = true) Instance Public methods 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: ActiveRecord::ReadOnlyRecord

new

new() Class Public methods

prepare_column_options

prepare_column_options(column, types) Instance Public methods Adds `:array` option to the default set provided by the AbstractAdapter