Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 320 lines (314 sloc) 14.248 kB
db045db @dhh Initial
dhh authored
1 require 'yaml'
a15e02d @josevalim Unify benchmark APIs.
josevalim authored
2 require 'active_support/benchmarkable'
f5d720f @jeremy Opt in to Dependencies
jeremy authored
3 require 'active_support/dependencies'
033e0a0 @josevalim ActiveRecord and ActionPack now use the new descendants implementation.
josevalim authored
4 require 'active_support/descendants_tracker'
5f222c5 @jeremy Remove 'core' fluff. Hookable ActiveSupport.load_all!
jeremy authored
5 require 'active_support/time'
6329d9f @gsamokovarov Remove deprecated cattr_* requires
gsamokovarov authored
6 require 'active_support/core_ext/module/attribute_accessors'
e8550ee @jeremy Cherry-pick core extensions
jeremy authored
7 require 'active_support/core_ext/array/extract_options'
8 require 'active_support/core_ext/hash/deep_merge'
9 require 'active_support/core_ext/hash/slice'
972d9be @sgrif Use `Hash#transform_values` to clean up `AttributeSet`
sgrif authored
10 require 'active_support/core_ext/hash/transform_values'
e8550ee @jeremy Cherry-pick core extensions
jeremy authored
11 require 'active_support/core_ext/string/behavior'
89978f1 @fxn moves Object#singleton_class to Kernel#singleton_class to match Ruby …
fxn authored
12 require 'active_support/core_ext/kernel/singleton_class'
4a8c880 @fxn refactors AR::Base#reset_table_name
fxn authored
13 require 'active_support/core_ext/module/introspection'
105f9b8 @fxn adds missing requires for Object#duplicable?
fxn authored
14 require 'active_support/core_ext/object/duplicable'
89b5b31 @diminish7 Added STI support to init and building associations
diminish7 authored
15 require 'active_support/core_ext/class/subclasses'
39d6f9e @wycats Make many parts of Rails lazy. In order to facilitate this,
wycats authored
16 require 'arel'
2dca1ba @sgrif Don't query the database schema when calling `serialize`
sgrif authored
17 require 'active_record/attribute_decorators'
39d6f9e @wycats Make many parts of Rails lazy. In order to facilitate this,
wycats authored
18 require 'active_record/errors'
6788db8 @josevalim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing f…
josevalim authored
19 require 'active_record/log_subscriber'
cfeac38 @fxn implements a much faster auto EXPLAIN, closes #3843 [José Valim & Xav…
fxn authored
20 require 'active_record/explain_subscriber'
74abdb1 @tenderlove move the cache to the AR models and populate it on inherited
tenderlove authored
21 require 'active_record/relation/delegation'
3fab9d8 @sgrif Rename `property` to `attribute`
sgrif authored
22 require 'active_record/attributes'
fb6df2a @sgrif Extract an explicit type caster class
sgrif authored
23 require 'active_record/type_caster'
db045db @dhh Initial
dhh authored
24
25 module ActiveRecord #:nodoc:
606088d @eac Mass assignment security refactoring
eac authored
26 # = Active Record
4ad6103 @rizwanreza Adds title and basic description where needed.
rizwanreza authored
27 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
28 # Active Record objects don't specify their attributes directly, but rather infer them from
29 # the table definition with which they're linked. Adding, removing, and changing attributes
30 # and their type is done directly in the database. Any change is instantly reflected in the
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
31 # Active Record objects. The mapping that binds a given Active Record class to a certain
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
32 # database table will happen automatically in most common cases, but can be overwritten for the uncommon ones.
33 #
20333be @tilsammans fix broken relative links [#5415 state:committed]
tilsammans authored
34 # See the mapping rules in table_name and the full example in link:files/activerecord/README_rdoc.html for more insight.
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
35 #
db045db @dhh Initial
dhh authored
36 # == Creation
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
37 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
38 # Active Records accept constructor parameters either in a hash or as a block. The hash
39 # method is especially useful when you're receiving the data from somewhere else, like an
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
40 # HTTP request. It works like this:
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
41 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
42 # user = User.new(name: "David", occupation: "Code Artist")
db045db @dhh Initial
dhh authored
43 # user.name # => "David"
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
44 #
db045db @dhh Initial
dhh authored
45 # You can also use block initialization:
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
46 #
db045db @dhh Initial
dhh authored
47 # user = User.new do |u|
48 # u.name = "David"
49 # u.occupation = "Code Artist"
50 # end
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
51 #
db045db @dhh Initial
dhh authored
52 # And of course you can just create a bare object and specify the attributes after the fact:
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
53 #
db045db @dhh Initial
dhh authored
54 # user = User.new
55 # user.name = "David"
56 # user.occupation = "Code Artist"
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
57 #
db045db @dhh Initial
dhh authored
58 # == Conditions
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
59 #
c5ec16e @dhh Added simple hash conditions to find that'll just convert hash to an …
dhh authored
60 # Conditions can either be specified as a string, array, or hash representing the WHERE-part of an SQL statement.
9e18380 @fxn Revert "Explicitly included hashes in sentence regarding SQL-injectio…
fxn authored
61 # The array form is to be used when the condition input is tainted and requires sanitization. The string form can
62 # be used for statements that don't involve tainted data. The hash form works much like the array form, except
63 # only equality and range is possible. Examples:
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
64 #
48052d7 @jeremy to_xml fixes, features, and speedup. Closes #4989.
jeremy authored
65 # class User < ActiveRecord::Base
db045db @dhh Initial
dhh authored
66 # def self.authenticate_unsafely(user_name, password)
2c27e3d @lifo Some doc updates reflecting the new query API
lifo authored
67 # where("user_name = '#{user_name}' AND password = '#{password}'").first
db045db @dhh Initial
dhh authored
68 # end
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
69 #
db045db @dhh Initial
dhh authored
70 # def self.authenticate_safely(user_name, password)
2c27e3d @lifo Some doc updates reflecting the new query API
lifo authored
71 # where("user_name = ? AND password = ?", user_name, password).first
db045db @dhh Initial
dhh authored
72 # end
c5ec16e @dhh Added simple hash conditions to find that'll just convert hash to an …
dhh authored
73 #
74 # def self.authenticate_safely_simply(user_name, password)
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
75 # where(user_name: user_name, password: password).first
c5ec16e @dhh Added simple hash conditions to find that'll just convert hash to an …
dhh authored
76 # end
db045db @dhh Initial
dhh authored
77 # end
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
78 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
79 # The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query
80 # and is thus susceptible to SQL-injection attacks if the <tt>user_name</tt> and +password+
04d37b0 @smartinez87 Remove extra whitespaces
smartinez87 authored
81 # parameters come directly from an HTTP request. The <tt>authenticate_safely</tt> and
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
82 # <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+
83 # before inserting them in the query, which will ensure that an attacker can't escape the
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
84 # query and fake the login (or worse).
2575b3b @dhh Added extra words of caution for guarding against SQL-injection attacks
dhh authored
85 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
86 # When using multiple parameters in the conditions, it can easily become hard to read exactly
87 # what the fourth or fifth question mark is supposed to represent. In those cases, you can
88 # resort to named bind variables instead. That's done by replacing the question marks with
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
89 # symbols and supplying a hash with values for the matching symbol keys:
5cd38ca @dhh Added documentation about named bind variables
dhh authored
90 #
2c27e3d @lifo Some doc updates reflecting the new query API
lifo authored
91 # Company.where(
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
92 # "id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
93 # { id: 3, name: "37signals", division: "First", accounting_date: '2005-01-01' }
2c27e3d @lifo Some doc updates reflecting the new query API
lifo authored
94 # ).first
5cd38ca @dhh Added documentation about named bind variables
dhh authored
95 #
c5ec16e @dhh Added simple hash conditions to find that'll just convert hash to an …
dhh authored
96 # Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND
97 # operator. For instance:
98 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
99 # Student.where(first_name: "Harvey", status: 1)
2c27e3d @lifo Some doc updates reflecting the new query API
lifo authored
100 # Student.where(params[:student])
c5ec16e @dhh Added simple hash conditions to find that'll just convert hash to an …
dhh authored
101 #
2876707 @jeremy Pass a range in :conditions to use the SQL BETWEEN operator. Closes #…
jeremy authored
102 # A range may be used in the hash to use the SQL BETWEEN operator:
103 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
104 # Student.where(grade: 9..12)
c5ec16e @dhh Added simple hash conditions to find that'll just convert hash to an …
dhh authored
105 #
aa4af60 @lifo Improve documentation.
lifo authored
106 # An array may be used in the hash to use the SQL IN operator:
107 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
108 # Student.where(grade: [9,11,12])
aa4af60 @lifo Improve documentation.
lifo authored
109 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
110 # When joining tables, nested hashes or keys written in the form 'table_name.column_name'
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
111 # can be used to qualify the table name of a particular condition. For instance:
e033b5d @lifo Merge docrails
lifo authored
112 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
113 # Student.joins(:schools).where(schools: { category: 'public' })
e552fe1 change activerecord query conditions example to avoid 'type' as colum…
Steve Bourne authored
114 # Student.joins(:schools).where('schools.category' => 'public' )
e033b5d @lifo Merge docrails
lifo authored
115 #
db045db @dhh Initial
dhh authored
116 # == Overwriting default accessors
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
117 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
118 # All column values are automatically available through basic accessors on the Active Record
119 # object, but sometimes you want to specialize this behavior. This can be done by overwriting
120 # the default accessors (using the same name as the attribute) and calling
228559e @senny Merge pull request #19787 from Senjai/patch-2
senny authored
121 # +super+ to actually change things.
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
122 #
db045db @dhh Initial
dhh authored
123 # class Song < ActiveRecord::Base
124 # # Uses an integer of seconds to hold the length of the song
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
125 #
db045db @dhh Initial
dhh authored
126 # def length=(minutes)
8f7d9eb @Senjai Encourage users to user super to override methods.
Senjai authored
127 # super(minutes.to_i * 60)
db045db @dhh Initial
dhh authored
128 # end
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
129 #
db045db @dhh Initial
dhh authored
130 # def length
8f7d9eb @Senjai Encourage users to user super to override methods.
Senjai authored
131 # super / 60
db045db @dhh Initial
dhh authored
132 # end
133 # end
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
134 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
135 # You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt>
8f7d9eb @Senjai Encourage users to user super to override methods.
Senjai authored
136 # or <tt>write_attribute(:attribute, value)</tt> and <tt>read_attribute(:attribute)</tt>.
0591c53 @dhh Made the dynamic finders use the new find API and updated the example…
dhh authored
137 #
e4d845e Document automatically generated predicate methods for attributes. Cl…
Marcel Molina authored
138 # == Attribute query methods
139 #
140 # In addition to the basic accessors, query methods are also automatically available on the Active Record object.
c9d86d4 @M7 Clarify that query methods have a custom definition of whether a nume…
M7 authored
141 # Query methods allow you to test whether an attribute value is present.
142 # Additionally, when dealing with numeric values, a query method will return false if the value is zero.
7367325 @jeremy Document Active Record exceptions. Closes #10444.
jeremy authored
143 #
e4d845e Document automatically generated predicate methods for attributes. Cl…
Marcel Molina authored
144 # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call
145 # to determine whether the user has a name:
146 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
147 # user = User.new(name: "David")
e4d845e Document automatically generated predicate methods for attributes. Cl…
Marcel Molina authored
148 # user.name? # => true
149 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
150 # anonymous = User.new(name: "")
e4d845e Document automatically generated predicate methods for attributes. Cl…
Marcel Molina authored
151 # anonymous.name? # => false
152 #
2948910 Misc doc fixes (typos/grammar/etc.). Closes #2430.
Marcel Molina authored
153 # == Accessing attributes before they have been typecasted
4eab375 @dhh Finished polishing API docs
dhh authored
154 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
155 # Sometimes you want to be able to read the raw attribute data without having the column-determined
156 # typecast run its course first. That can be done by using the <tt><attribute>_before_type_cast</tt>
157 # accessors that all attributes have. For example, if your Account model has a <tt>balance</tt> attribute,
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
158 # you can call <tt>account.balance_before_type_cast</tt> or <tt>account.id_before_type_cast</tt>.
4eab375 @dhh Finished polishing API docs
dhh authored
159 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
160 # This is especially useful in validation situations where the user might supply a string for an
161 # integer field and you want to display the original string back in an error message. Accessing the
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
162 # attribute normally would typecast the string to 0, which isn't what you want.
4eab375 @dhh Finished polishing API docs
dhh authored
163 #
ac8fd7d @dhh Added dynamic attribute-based finders as a cleaner way of getting obj…
dhh authored
164 # == Dynamic attribute-based finders
165 #
04cda18 @rubys Prefer find_by over dynamic finders in rdoc
rubys authored
166 # Dynamic attribute-based finders are a mildly deprecated way of getting (and/or creating) objects
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
167 # by simple queries without turning to SQL. They work by appending the name of an attribute
7bb34b1 @tbaba Remove useless number sign
tbaba authored
168 # to <tt>find_by_</tt> like <tt>Person.find_by_user_name</tt>.
04cda18 @rubys Prefer find_by over dynamic finders in rdoc
rubys authored
169 # Instead of writing <tt>Person.find_by(user_name: user_name)</tt>, you can use
44717a9 @amatsuda find_last_by is deprecated in AR 4
amatsuda authored
170 # <tt>Person.find_by_user_name(user_name)</tt>.
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
171 #
56efdbc Document exclamation point on dynamic finders
Florent Guilleux authored
172 # It's possible to add an exclamation point (!) on the end of the dynamic finders to get them to raise an
0d5a6f6 @jonleighton In 1efd88283ef68d912df215125951a87526768a51, ConnectionAdapters was p…
jonleighton authored
173 # <tt>ActiveRecord::RecordNotFound</tt> error if they do not return any records,
56efdbc Document exclamation point on dynamic finders
Florent Guilleux authored
174 # like <tt>Person.find_by_last_name!</tt>.
175 #
d3eacf9 @neerajdotname Adding to AR::Base documentation about dynamically scopeded_by query
neerajdotname authored
176 # It's also possible to use multiple attributes in the same find by separating them with "_and_".
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
177 #
04cda18 @rubys Prefer find_by over dynamic finders in rdoc
rubys authored
178 # Person.find_by(user_name: user_name, password: password)
2acb5e3 @fxn removes unrealistic example (authentication plus gender?), that it is…
fxn authored
179 # Person.find_by_user_name_and_password(user_name, password) # with dynamic finder
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
180 #
d3eacf9 @neerajdotname Adding to AR::Base documentation about dynamically scopeded_by query
neerajdotname authored
181 # It's even possible to call these dynamic finder methods on relations and named scopes.
2c27e3d @lifo Some doc updates reflecting the new query API
lifo authored
182 #
ad82753 @amatsuda find_all_by is deprecated in AR 4
amatsuda authored
183 # Payment.order("created_on").find_by_amount(50)
959f362 @dhh Added find_all style to the new dynamic finders
dhh authored
184 #
098fa94 @dhh Fixed documentation snafus #575, #576, #577, #585
dhh authored
185 # == Saving arrays, hashes, and other non-mappable objects in text columns
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
186 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
187 # Active Record can serialize any object in text columns using YAML. To do so, you must
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
188 # specify this with a call to the class method +serialize+.
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
189 # This makes it possible to store arrays, hashes, and other non-mappable objects without doing
190 # any additional work.
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
191 #
db045db @dhh Initial
dhh authored
192 # class User < ActiveRecord::Base
193 # serialize :preferences
194 # end
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
195 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
196 # user = User.create(preferences: { "background" => "black", "display" => large })
db045db @dhh Initial
dhh authored
197 # User.find(user.id).preferences # => { "background" => "black", "display" => large }
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
198 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
199 # You can also specify a class option as the second parameter that'll raise an exception
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
200 # if a serialized object is retrieved as a descendant of a class not in the hierarchy.
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
201 #
db045db @dhh Initial
dhh authored
202 # class User < ActiveRecord::Base
66f44e6 @dhh Updated documentation for serialize
dhh authored
203 # serialize :preferences, Hash
db045db @dhh Initial
dhh authored
204 # end
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
205 #
3c58018 @AvnerCohen 1.9 hash syntax changes
AvnerCohen authored
206 # user = User.create(preferences: %w( one two three ))
db045db @dhh Initial
dhh authored
207 # User.find(user.id).preferences # raises SerializationTypeMismatch
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
208 #
351331f @guillermo Make serialized columns with explicit object_type return a new instan…
guillermo authored
209 # When you specify a class option, the default value for that attribute will be a new
210 # instance of that class.
211 #
212 # class User < ActiveRecord::Base
213 # serialize :preferences, OpenStruct
214 # end
215 #
216 # user = User.new
217 # user.preferences.theme_color = "red"
218 #
219 #
db045db @dhh Initial
dhh authored
220 # == Single table inheritance
221 #
088b4c3 @sgrif Move STI docs off of the main Base document, leaving a note
sgrif authored
222 # Active Record allows inheritance by storing the name of the class in a
223 # column that is named "type" by default. See ActiveRecord::Inheritance for
224 # more details.
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
225 #
db045db @dhh Initial
dhh authored
226 # == Connection to multiple databases in different models
227 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
228 # Connections are usually created through ActiveRecord::Base.establish_connection and retrieved
229 # by ActiveRecord::Base.connection. All classes inheriting from ActiveRecord::Base will use this
230 # connection. But you can also set a class-specific connection. For example, if Course is an
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
231 # ActiveRecord::Base, but resides in a different database, you can just say <tt>Course.establish_connection</tt>
98dc582 @lifo Merge docrails.
lifo authored
232 # and Course and all of its subclasses will use this connection instead.
db045db @dhh Initial
dhh authored
233 #
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
234 # This feature is implemented by keeping a connection pool in ActiveRecord::Base that is
235 # a Hash indexed by the class. If a connection is requested, the retrieve_connection method
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
236 # will go up the class-hierarchy until a connection is found in the connection pool.
db045db @dhh Initial
dhh authored
237 #
238 # == Exceptions
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
239 #
dc4eec1 @lifo Merge docrails:
lifo authored
240 # * ActiveRecordError - Generic error class and superclass of all other errors raised by Active Record.
241 # * AdapterNotSpecified - The configuration hash used in <tt>establish_connection</tt> didn't include an
db045db @dhh Initial
dhh authored
242 # <tt>:adapter</tt> key.
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
243 # * AdapterNotFound - The <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
244 # non-existent adapter
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
245 # (or a bad spelling of an existing one).
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
246 # * AssociationTypeMismatch - The object assigned to the association wasn't of the type
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
247 # specified in the association definition.
620cc9a @shime add ActiveRecord::RecordInvalid to exceptions
shime authored
248 # * AttributeAssignmentError - An error occurred while doing a mass assignment through the
249 # <tt>attributes=</tt> method.
250 # You can inspect the +attribute+ property of the exception object to determine which attribute
251 # triggered the error.
cf9664a @vijaydev fix markup error [ci skip]
vijaydev authored
252 # * ConnectionNotEstablished - No connection has been established. Use <tt>establish_connection</tt>
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
253 # before querying.
dc4eec1 @lifo Merge docrails:
lifo authored
254 # * MultiparameterAssignmentErrors - Collection of errors that occurred during a mass assignment using the
b451de0 @spastorino Deletes trailing whitespaces (over text files only find * -type f -ex…
spastorino authored
255 # <tt>attributes=</tt> method. The +errors+ property of this exception contains an array of
b8d9d9c @neerajdotname updating documentation to ensure line does not exceed 100 columns
neerajdotname authored
256 # AttributeAssignmentError
d2fefbe @dhh Added MultiparameterAssignmentErrors and AttributeAssignmentError exc…
dhh authored
257 # objects that should be inspected to determine which attributes triggered the errors.
a7ad06e @yui-knk [ci skip] Add <tt> tag to `save!` and `create!`
yui-knk authored
258 # * RecordInvalid - raised by <tt>save!</tt> and <tt>create!</tt> when the record is invalid.
620cc9a @shime add ActiveRecord::RecordInvalid to exceptions
shime authored
259 # * RecordNotFound - No record responded to the +find+ method. Either the row with the given ID doesn't exist
260 # or the row didn't meet the additional restrictions. Some +find+ calls do not raise this exception to signal
261 # nothing was found, please check its documentation for further details.
262 # * SerializationTypeMismatch - The serialized object wasn't of the class specified as the second parameter.
263 # * StatementInvalid - The database server rejected the SQL statement. The precise error is added in the message.
5707027 @dhh Added better exception error when unknown column types are used with …
dhh authored
264 #
6e39c9e @jeremy r1614@asus: jeremy | 2005-07-03 08:01:08 -0700
jeremy authored
265 # *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level).
dc4eec1 @lifo Merge docrails:
lifo authored
266 # So it's possible to assign a logger to the class through <tt>Base.logger=</tt> which will then be used by all
db045db @dhh Initial
dhh authored
267 # instances in the current object space.
268 class Base
9e4c41c @jonleighton Remove ActiveRecord::Model
jonleighton authored
269 extend ActiveModel::Naming
270
271 extend ActiveSupport::Benchmarkable
272 extend ActiveSupport::DescendantsTracker
273
274 extend ConnectionHandling
275 extend QueryCache::ClassMethods
276 extend Querying
277 extend Translation
278 extend DynamicMatchers
279 extend Explain
db41eb8 @dhh Added ActiveRecord::Base#enum for declaring enum attributes where the…
dhh authored
280 extend Enum
74abdb1 @tenderlove move the cache to the AR models and populate it on inherited
tenderlove authored
281 extend Delegation::DelegateCache
476e3f5 @afcapel Add #cache_key to ActiveRecord::Relation.
afcapel authored
282 extend CollectionCacheKey
9e4c41c @jonleighton Remove ActiveRecord::Model
jonleighton authored
283
7240300 @kbrock put core at the beginning so other classes can modify the behavior
kbrock authored
284 include Core
9e4c41c @jonleighton Remove ActiveRecord::Model
jonleighton authored
285 include Persistence
286 include ReadonlyAttributes
287 include ModelSchema
288 include Inheritance
289 include Scoping
290 include Sanitization
291 include AttributeAssignment
292 include ActiveModel::Conversion
293 include Integration
294 include Validations
295 include CounterCache
74af9f7 @sgrif Promote time zone aware attributes to a first class type decorator
sgrif authored
296 include Attributes
297 include AttributeDecorators
e30d701 @sgrif Don't mess with `column_defaults` when optimistic locking is enabled
sgrif authored
298 include Locking::Optimistic
299 include Locking::Pessimistic
9e4c41c @jonleighton Remove ActiveRecord::Model
jonleighton authored
300 include AttributeMethods
dd3ea17 @rafaelfranca Merge pull request #14469 from tiegz/timestamp_inheritance_fix
rafaelfranca authored
301 include Callbacks
dddbccb @rafaelfranca Timestamp values should be present on callbacks
rafaelfranca authored
302 include Timestamp
9e4c41c @jonleighton Remove ActiveRecord::Model
jonleighton authored
303 include Associations
304 include ActiveModel::SecurePassword
305 include AutosaveAssociation
306 include NestedAttributes
307 include Aggregations
308 include Transactions
4866399 @lucasmazza `ActiveRecord::Base.no_touching` no longer triggers callbacks or star…
lucasmazza authored
309 include NoTouching
8971389 @arthurnn Batch touch parent records
arthurnn authored
310 include TouchLater
9e4c41c @jonleighton Remove ActiveRecord::Model
jonleighton authored
311 include Reflection
312 include Serialization
313 include Store
5a58ba3 @robertomiranda Add has_secure_token to Active Record
robertomiranda authored
314 include SecureToken
b9a1e9a @perceptec Add `ActiveRecord::Base.suppress`
perceptec authored
315 include Suppressor
7254d23 @josh Autoload ActiveRecord files
josh authored
316 end
4ed1563 @jeremy Revert "Get rid of the ActiveRecord::Model::DeprecationProxy thing."
jeremy authored
317
9e4c41c @jonleighton Remove ActiveRecord::Model
jonleighton authored
318 ActiveSupport.run_load_hooks(:active_record, Base)
319 end
Something went wrong with that request. Please try again.