2004-11-23 20:04:44 -05:00
|
|
|
require 'yaml'
|
2005-11-02 12:30:59 -05:00
|
|
|
require 'set'
|
2009-10-09 08:52:25 -04:00
|
|
|
require 'active_support/benchmarkable'
|
2009-04-22 19:41:06 -04:00
|
|
|
require 'active_support/dependencies'
|
2010-06-19 11:15:21 -04:00
|
|
|
require 'active_support/descendants_tracker'
|
2009-05-20 20:11:41 -04:00
|
|
|
require 'active_support/time'
|
2013-12-02 16:36:58 -05:00
|
|
|
require 'active_support/core_ext/module/attribute_accessors'
|
2009-05-13 04:10:37 -04:00
|
|
|
require 'active_support/core_ext/class/delegating_attributes'
|
|
|
|
require 'active_support/core_ext/array/extract_options'
|
|
|
|
require 'active_support/core_ext/hash/deep_merge'
|
|
|
|
require 'active_support/core_ext/hash/slice'
|
2014-06-29 17:31:35 -04:00
|
|
|
require 'active_support/core_ext/hash/transform_values'
|
2009-05-13 04:10:37 -04:00
|
|
|
require 'active_support/core_ext/string/behavior'
|
2010-04-05 15:15:08 -04:00
|
|
|
require 'active_support/core_ext/kernel/singleton_class'
|
2010-06-14 12:36:04 -04:00
|
|
|
require 'active_support/core_ext/module/introspection'
|
2010-03-28 07:26:13 -04:00
|
|
|
require 'active_support/core_ext/object/duplicable'
|
2012-04-05 15:21:48 -04:00
|
|
|
require 'active_support/core_ext/class/subclasses'
|
2010-03-07 09:24:30 -05:00
|
|
|
require 'arel'
|
2014-06-06 11:43:09 -04:00
|
|
|
require 'active_record/attribute_decorators'
|
2010-03-07 09:24:30 -05:00
|
|
|
require 'active_record/errors'
|
2010-06-24 07:23:43 -04:00
|
|
|
require 'active_record/log_subscriber'
|
2011-12-04 14:29:56 -05:00
|
|
|
require 'active_record/explain_subscriber'
|
2013-08-30 19:48:20 -04:00
|
|
|
require 'active_record/relation/delegation'
|
2014-06-07 09:09:45 -04:00
|
|
|
require 'active_record/attributes'
|
2014-12-29 13:07:56 -05:00
|
|
|
require 'active_record/type_caster'
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
module ActiveRecord #:nodoc:
|
2010-01-29 20:02:12 -05:00
|
|
|
# = Active Record
|
2010-06-15 14:11:41 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# Active Record objects don't specify their attributes directly, but rather infer them from
|
|
|
|
# the table definition with which they're linked. Adding, removing, and changing attributes
|
|
|
|
# and their type is done directly in the database. Any change is instantly reflected in the
|
2010-08-02 11:09:31 -04:00
|
|
|
# Active Record objects. The mapping that binds a given Active Record class to a certain
|
2005-07-03 04:32:43 -04:00
|
|
|
# database table will happen automatically in most common cases, but can be overwritten for the uncommon ones.
|
|
|
|
#
|
2010-08-24 06:22:54 -04:00
|
|
|
# See the mapping rules in table_name and the full example in link:files/activerecord/README_rdoc.html for more insight.
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# == Creation
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# Active Records accept constructor parameters either in a hash or as a block. The hash
|
|
|
|
# method is especially useful when you're receiving the data from somewhere else, like an
|
2010-08-02 11:09:31 -04:00
|
|
|
# HTTP request. It works like this:
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# user = User.new(name: "David", occupation: "Code Artist")
|
2004-11-23 20:04:44 -05:00
|
|
|
# user.name # => "David"
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# You can also use block initialization:
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# user = User.new do |u|
|
|
|
|
# u.name = "David"
|
|
|
|
# u.occupation = "Code Artist"
|
|
|
|
# end
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# And of course you can just create a bare object and specify the attributes after the fact:
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# user = User.new
|
|
|
|
# user.name = "David"
|
|
|
|
# user.occupation = "Code Artist"
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# == Conditions
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2006-06-03 18:15:06 -04:00
|
|
|
# Conditions can either be specified as a string, array, or hash representing the WHERE-part of an SQL statement.
|
2011-08-04 18:14:06 -04:00
|
|
|
# The array form is to be used when the condition input is tainted and requires sanitization. The string form can
|
|
|
|
# be used for statements that don't involve tainted data. The hash form works much like the array form, except
|
|
|
|
# only equality and range is possible. Examples:
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2006-06-02 20:01:08 -04:00
|
|
|
# class User < ActiveRecord::Base
|
2004-11-23 20:04:44 -05:00
|
|
|
# def self.authenticate_unsafely(user_name, password)
|
2010-04-08 11:49:38 -04:00
|
|
|
# where("user_name = '#{user_name}' AND password = '#{password}'").first
|
2004-11-23 20:04:44 -05:00
|
|
|
# end
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# def self.authenticate_safely(user_name, password)
|
2010-04-08 11:49:38 -04:00
|
|
|
# where("user_name = ? AND password = ?", user_name, password).first
|
2004-11-23 20:04:44 -05:00
|
|
|
# end
|
2006-06-03 18:15:06 -04:00
|
|
|
#
|
|
|
|
# def self.authenticate_safely_simply(user_name, password)
|
2012-11-08 16:16:54 -05:00
|
|
|
# where(user_name: user_name, password: password).first
|
2006-06-03 18:15:06 -04:00
|
|
|
# end
|
2004-11-23 20:04:44 -05:00
|
|
|
# end
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query
|
|
|
|
# and is thus susceptible to SQL-injection attacks if the <tt>user_name</tt> and +password+
|
2011-05-02 09:37:34 -04:00
|
|
|
# parameters come directly from an HTTP request. The <tt>authenticate_safely</tt> and
|
2010-08-14 01:13:00 -04:00
|
|
|
# <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+
|
|
|
|
# before inserting them in the query, which will ensure that an attacker can't escape the
|
2010-08-02 11:09:31 -04:00
|
|
|
# query and fake the login (or worse).
|
2004-12-06 13:08:35 -05:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# When using multiple parameters in the conditions, it can easily become hard to read exactly
|
|
|
|
# what the fourth or fifth question mark is supposed to represent. In those cases, you can
|
|
|
|
# resort to named bind variables instead. That's done by replacing the question marks with
|
2010-08-02 11:09:31 -04:00
|
|
|
# symbols and supplying a hash with values for the matching symbol keys:
|
2005-03-27 07:04:07 -05:00
|
|
|
#
|
2010-04-08 11:49:38 -04:00
|
|
|
# Company.where(
|
2005-07-03 04:32:43 -04:00
|
|
|
# "id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
|
2012-11-08 16:16:54 -05:00
|
|
|
# { id: 3, name: "37signals", division: "First", accounting_date: '2005-01-01' }
|
2010-04-08 11:49:38 -04:00
|
|
|
# ).first
|
2005-03-27 07:04:07 -05:00
|
|
|
#
|
2006-06-03 18:15:06 -04:00
|
|
|
# Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND
|
|
|
|
# operator. For instance:
|
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# Student.where(first_name: "Harvey", status: 1)
|
2010-04-08 11:49:38 -04:00
|
|
|
# Student.where(params[:student])
|
2006-06-03 18:15:06 -04:00
|
|
|
#
|
2007-01-10 05:13:18 -05:00
|
|
|
# A range may be used in the hash to use the SQL BETWEEN operator:
|
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# Student.where(grade: 9..12)
|
2006-06-03 18:15:06 -04:00
|
|
|
#
|
2008-04-04 23:52:58 -04:00
|
|
|
# An array may be used in the hash to use the SQL IN operator:
|
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# Student.where(grade: [9,11,12])
|
2008-04-04 23:52:58 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# When joining tables, nested hashes or keys written in the form 'table_name.column_name'
|
2010-08-02 11:09:31 -04:00
|
|
|
# can be used to qualify the table name of a particular condition. For instance:
|
2009-07-25 11:03:58 -04:00
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# Student.joins(:schools).where(schools: { category: 'public' })
|
2011-10-12 13:46:08 -04:00
|
|
|
# Student.joins(:schools).where('schools.category' => 'public' )
|
2009-07-25 11:03:58 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# == Overwriting default accessors
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# All column values are automatically available through basic accessors on the Active Record
|
|
|
|
# object, but sometimes you want to specialize this behavior. This can be done by overwriting
|
|
|
|
# the default accessors (using the same name as the attribute) and calling
|
|
|
|
# <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually
|
2010-08-02 11:09:31 -04:00
|
|
|
# change things.
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# class Song < ActiveRecord::Base
|
|
|
|
# # Uses an integer of seconds to hold the length of the song
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# def length=(minutes)
|
2008-05-02 09:45:23 -04:00
|
|
|
# write_attribute(:length, minutes.to_i * 60)
|
2004-11-23 20:04:44 -05:00
|
|
|
# end
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# def length
|
2005-04-17 13:16:24 -04:00
|
|
|
# read_attribute(:length) / 60
|
2004-11-23 20:04:44 -05:00
|
|
|
# end
|
|
|
|
# end
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt>
|
2010-08-02 11:09:31 -04:00
|
|
|
# instead of <tt>write_attribute(:attribute, value)</tt> and <tt>read_attribute(:attribute)</tt>.
|
2005-04-17 13:16:24 -04:00
|
|
|
#
|
2007-12-05 09:22:26 -05:00
|
|
|
# == Attribute query methods
|
|
|
|
#
|
|
|
|
# In addition to the basic accessors, query methods are also automatically available on the Active Record object.
|
2014-12-23 19:32:49 -05:00
|
|
|
# Query methods allow you to test whether an attribute value is present.
|
|
|
|
# Additionally, when dealing with numeric values, a query method will return false if the value is zero.
|
2007-12-09 23:13:33 -05:00
|
|
|
#
|
2007-12-05 09:22:26 -05:00
|
|
|
# For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call
|
|
|
|
# to determine whether the user has a name:
|
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# user = User.new(name: "David")
|
2007-12-05 09:22:26 -05:00
|
|
|
# user.name? # => true
|
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# anonymous = User.new(name: "")
|
2007-12-05 09:22:26 -05:00
|
|
|
# anonymous.name? # => false
|
|
|
|
#
|
2005-10-10 23:55:49 -04:00
|
|
|
# == Accessing attributes before they have been typecasted
|
2005-02-23 18:51:34 -05:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# Sometimes you want to be able to read the raw attribute data without having the column-determined
|
|
|
|
# typecast run its course first. That can be done by using the <tt><attribute>_before_type_cast</tt>
|
|
|
|
# accessors that all attributes have. For example, if your Account model has a <tt>balance</tt> attribute,
|
2010-08-02 11:09:31 -04:00
|
|
|
# you can call <tt>account.balance_before_type_cast</tt> or <tt>account.id_before_type_cast</tt>.
|
2005-02-23 18:51:34 -05:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# This is especially useful in validation situations where the user might supply a string for an
|
|
|
|
# integer field and you want to display the original string back in an error message. Accessing the
|
2010-08-02 11:09:31 -04:00
|
|
|
# attribute normally would typecast the string to 0, which isn't what you want.
|
2005-02-23 18:51:34 -05:00
|
|
|
#
|
2005-01-02 08:31:00 -05:00
|
|
|
# == Dynamic attribute-based finders
|
|
|
|
#
|
2013-04-02 15:09:15 -04:00
|
|
|
# Dynamic attribute-based finders are a mildly deprecated way of getting (and/or creating) objects
|
2010-08-14 01:13:00 -04:00
|
|
|
# by simple queries without turning to SQL. They work by appending the name of an attribute
|
2013-01-18 04:14:18 -05:00
|
|
|
# to <tt>find_by_</tt> like <tt>Person.find_by_user_name</tt>.
|
2013-04-02 15:09:15 -04:00
|
|
|
# Instead of writing <tt>Person.find_by(user_name: user_name)</tt>, you can use
|
2013-01-01 14:42:47 -05:00
|
|
|
# <tt>Person.find_by_user_name(user_name)</tt>.
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2011-08-08 20:31:03 -04:00
|
|
|
# It's possible to add an exclamation point (!) on the end of the dynamic finders to get them to raise an
|
2011-08-16 10:01:18 -04:00
|
|
|
# <tt>ActiveRecord::RecordNotFound</tt> error if they do not return any records,
|
2011-08-08 20:31:03 -04:00
|
|
|
# like <tt>Person.find_by_last_name!</tt>.
|
|
|
|
#
|
2010-08-02 13:07:18 -04:00
|
|
|
# It's also possible to use multiple attributes in the same find by separating them with "_and_".
|
2010-08-14 01:13:00 -04:00
|
|
|
#
|
2013-04-02 15:09:15 -04:00
|
|
|
# Person.find_by(user_name: user_name, password: password)
|
2011-02-18 16:54:02 -05:00
|
|
|
# Person.find_by_user_name_and_password(user_name, password) # with dynamic finder
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2010-08-02 13:07:18 -04:00
|
|
|
# It's even possible to call these dynamic finder methods on relations and named scopes.
|
2010-04-08 11:49:38 -04:00
|
|
|
#
|
2013-01-01 14:36:33 -05:00
|
|
|
# Payment.order("created_on").find_by_amount(50)
|
2005-01-02 08:51:00 -05:00
|
|
|
#
|
2005-02-07 09:15:53 -05:00
|
|
|
# == Saving arrays, hashes, and other non-mappable objects in text columns
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# Active Record can serialize any object in text columns using YAML. To do so, you must
|
2010-08-02 11:09:31 -04:00
|
|
|
# specify this with a call to the class method +serialize+.
|
2010-08-14 01:13:00 -04:00
|
|
|
# This makes it possible to store arrays, hashes, and other non-mappable objects without doing
|
|
|
|
# any additional work.
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# class User < ActiveRecord::Base
|
|
|
|
# serialize :preferences
|
|
|
|
# end
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# user = User.create(preferences: { "background" => "black", "display" => large })
|
2004-11-23 20:04:44 -05:00
|
|
|
# User.find(user.id).preferences # => { "background" => "black", "display" => large }
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# You can also specify a class option as the second parameter that'll raise an exception
|
2010-08-02 11:09:31 -04:00
|
|
|
# if a serialized object is retrieved as a descendant of a class not in the hierarchy.
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# class User < ActiveRecord::Base
|
2005-01-25 15:00:20 -05:00
|
|
|
# serialize :preferences, Hash
|
2004-11-23 20:04:44 -05:00
|
|
|
# end
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2012-11-08 16:16:54 -05:00
|
|
|
# user = User.create(preferences: %w( one two three ))
|
2004-11-23 20:04:44 -05:00
|
|
|
# User.find(user.id).preferences # raises SerializationTypeMismatch
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2011-02-02 18:26:39 -05:00
|
|
|
# When you specify a class option, the default value for that attribute will be a new
|
|
|
|
# instance of that class.
|
|
|
|
#
|
|
|
|
# class User < ActiveRecord::Base
|
|
|
|
# serialize :preferences, OpenStruct
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# user = User.new
|
|
|
|
# user.preferences.theme_color = "red"
|
|
|
|
#
|
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# == Single table inheritance
|
|
|
|
#
|
2014-06-30 11:29:32 -04:00
|
|
|
# Active Record allows inheritance by storing the name of the class in a
|
|
|
|
# column that is named "type" by default. See ActiveRecord::Inheritance for
|
|
|
|
# more details.
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2004-11-23 20:04:44 -05:00
|
|
|
# == Connection to multiple databases in different models
|
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# Connections are usually created through ActiveRecord::Base.establish_connection and retrieved
|
|
|
|
# by ActiveRecord::Base.connection. All classes inheriting from ActiveRecord::Base will use this
|
|
|
|
# connection. But you can also set a class-specific connection. For example, if Course is an
|
2010-08-02 11:09:31 -04:00
|
|
|
# ActiveRecord::Base, but resides in a different database, you can just say <tt>Course.establish_connection</tt>
|
2008-05-25 07:29:00 -04:00
|
|
|
# and Course and all of its subclasses will use this connection instead.
|
2004-11-23 20:04:44 -05:00
|
|
|
#
|
2010-08-14 01:13:00 -04:00
|
|
|
# This feature is implemented by keeping a connection pool in ActiveRecord::Base that is
|
|
|
|
# a Hash indexed by the class. If a connection is requested, the retrieve_connection method
|
2010-08-02 11:09:31 -04:00
|
|
|
# will go up the class-hierarchy until a connection is found in the connection pool.
|
2004-11-23 20:04:44 -05:00
|
|
|
#
|
|
|
|
# == Exceptions
|
2005-07-03 04:32:43 -04:00
|
|
|
#
|
2008-05-09 05:38:02 -04:00
|
|
|
# * ActiveRecordError - Generic error class and superclass of all other errors raised by Active Record.
|
|
|
|
# * AdapterNotSpecified - The configuration hash used in <tt>establish_connection</tt> didn't include an
|
2004-11-23 20:04:44 -05:00
|
|
|
# <tt>:adapter</tt> key.
|
2010-08-14 01:13:00 -04:00
|
|
|
# * AdapterNotFound - The <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a
|
2010-08-02 11:09:31 -04:00
|
|
|
# non-existent adapter
|
2005-07-03 04:32:43 -04:00
|
|
|
# (or a bad spelling of an existing one).
|
2010-08-14 01:13:00 -04:00
|
|
|
# * AssociationTypeMismatch - The object assigned to the association wasn't of the type
|
2010-08-02 11:09:31 -04:00
|
|
|
# specified in the association definition.
|
2012-04-30 08:46:30 -04:00
|
|
|
# * AttributeAssignmentError - An error occurred while doing a mass assignment through the
|
|
|
|
# <tt>attributes=</tt> method.
|
|
|
|
# You can inspect the +attribute+ property of the exception object to determine which attribute
|
|
|
|
# triggered the error.
|
2012-04-07 16:43:51 -04:00
|
|
|
# * ConnectionNotEstablished - No connection has been established. Use <tt>establish_connection</tt>
|
2010-08-02 11:09:31 -04:00
|
|
|
# before querying.
|
2008-05-09 05:38:02 -04:00
|
|
|
# * MultiparameterAssignmentErrors - Collection of errors that occurred during a mass assignment using the
|
2010-08-14 01:13:00 -04:00
|
|
|
# <tt>attributes=</tt> method. The +errors+ property of this exception contains an array of
|
2010-08-02 11:09:31 -04:00
|
|
|
# AttributeAssignmentError
|
2005-03-06 09:11:26 -05:00
|
|
|
# objects that should be inspected to determine which attributes triggered the errors.
|
2012-05-01 09:48:47 -04:00
|
|
|
# * RecordInvalid - raised by save! and create! when the record is invalid.
|
2012-04-30 08:46:30 -04:00
|
|
|
# * RecordNotFound - No record responded to the +find+ method. Either the row with the given ID doesn't exist
|
|
|
|
# or the row didn't meet the additional restrictions. Some +find+ calls do not raise this exception to signal
|
|
|
|
# nothing was found, please check its documentation for further details.
|
|
|
|
# * SerializationTypeMismatch - The serialized object wasn't of the class specified as the second parameter.
|
|
|
|
# * StatementInvalid - The database server rejected the SQL statement. The precise error is added in the message.
|
2005-09-11 05:41:24 -04:00
|
|
|
#
|
2005-07-03 04:32:43 -04:00
|
|
|
# *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level).
|
2008-05-09 05:38:02 -04:00
|
|
|
# So it's possible to assign a logger to the class through <tt>Base.logger=</tt> which will then be used by all
|
2004-11-23 20:04:44 -05:00
|
|
|
# instances in the current object space.
|
|
|
|
class Base
|
2012-10-26 10:51:02 -04:00
|
|
|
extend ActiveModel::Naming
|
|
|
|
|
|
|
|
extend ActiveSupport::Benchmarkable
|
|
|
|
extend ActiveSupport::DescendantsTracker
|
|
|
|
|
|
|
|
extend ConnectionHandling
|
|
|
|
extend QueryCache::ClassMethods
|
|
|
|
extend Querying
|
|
|
|
extend Translation
|
|
|
|
extend DynamicMatchers
|
|
|
|
extend Explain
|
2013-11-02 15:01:31 -04:00
|
|
|
extend Enum
|
2013-08-30 19:48:20 -04:00
|
|
|
extend Delegation::DelegateCache
|
2012-10-26 10:51:02 -04:00
|
|
|
|
2014-01-22 09:28:19 -05:00
|
|
|
include Core
|
2012-10-26 10:51:02 -04:00
|
|
|
include Persistence
|
|
|
|
include ReadonlyAttributes
|
|
|
|
include ModelSchema
|
|
|
|
include Inheritance
|
|
|
|
include Scoping
|
|
|
|
include Sanitization
|
|
|
|
include AttributeAssignment
|
|
|
|
include ActiveModel::Conversion
|
|
|
|
include Integration
|
|
|
|
include Validations
|
|
|
|
include CounterCache
|
2014-06-16 16:55:01 -04:00
|
|
|
include Attributes
|
|
|
|
include AttributeDecorators
|
2014-06-17 11:41:06 -04:00
|
|
|
include Locking::Optimistic
|
|
|
|
include Locking::Pessimistic
|
2012-10-26 10:51:02 -04:00
|
|
|
include AttributeMethods
|
2014-03-27 17:10:17 -04:00
|
|
|
include Callbacks
|
2014-06-09 16:25:20 -04:00
|
|
|
include Timestamp
|
2012-10-26 10:51:02 -04:00
|
|
|
include Associations
|
|
|
|
include ActiveModel::SecurePassword
|
|
|
|
include AutosaveAssociation
|
|
|
|
include NestedAttributes
|
|
|
|
include Aggregations
|
|
|
|
include Transactions
|
2014-04-23 00:37:13 -04:00
|
|
|
include NoTouching
|
2012-10-26 10:51:02 -04:00
|
|
|
include Reflection
|
|
|
|
include Serialization
|
|
|
|
include Store
|
2014-12-28 17:24:10 -05:00
|
|
|
include SecureToken
|
2015-02-18 17:55:48 -05:00
|
|
|
include Suppressor
|
2008-11-24 12:14:24 -05:00
|
|
|
end
|
2012-10-20 14:35:16 -04:00
|
|
|
|
2012-10-26 10:51:02 -04:00
|
|
|
ActiveSupport.run_load_hooks(:active_record, Base)
|
|
|
|
end
|