1 *1.15.2* (February 5th, 2007)
3 * Pass a range in :conditions to use the SQL BETWEEN operator. #6974 [dcmanges]
4 Student.find(:all, :conditions => { :grade => 9..12 })
6 * Don't create instance writer methods for class attributes. [Rick]
8 * When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck]
10 * SQLServer: don't choke on strings containing 'null'. #7083 [Jakob S]
12 * Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si]
14 * MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc]
16 * Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden]
18 * SQLServer: quote table name in indexes query. #2928 [keithm@infused.org]
21 *1.15.1* (January 17th, 2007)
23 * Fix nodoc breaking of adapters
26 *1.15.0* (January 16th, 2007)
28 * [DOC] clear up some ambiguity with the way has_and_belongs_to_many creates the default join table name. #7072 [jeremymcanally]
30 * change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [dcmanges, Jeremy Kemper]
32 * MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, manfred, altano@bigfoot.com]
34 * Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. #7000 [Michael Schoen]
36 * MySQL: retain SSL settings on reconnect. #6976 [randyv2]
38 * SQLServer: handle [quoted] table names. #6635 [rrich]
40 * acts_as_nested_set works with single-table inheritance. #6030 [Josh Susser]
42 * PostgreSQL, Oracle: correctly perform eager finds with :limit and :order. #4668, #7021 [eventualbuddha, Michael Schoen]
44 * Fix the Oracle adapter for serialized attributes stored in CLOBs. Closes #6825 [mschoen, tdfowler]
46 * [DOCS] Apply more documentation for ActiveRecord Reflection. Closes #4055 [Robby Russell]
48 * [DOCS] Document :allow_nil option of #validate_uniqueness_of. Closes #3143 [Caio Chassot]
50 * Bring the sybase adapter up to scratch for 1.2 release. [jsheets]
52 * Oracle: fix connection reset failure. #6846 [leonlleslie]
54 * Subclass instantiation doesn't try to explicitly require the corresponding subclass. #6840 [leei, Jeremy Kemper]
56 * fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool]
58 * find supports :lock with :include. Check whether your database allows SELECT ... FOR UPDATE with outer joins before using. #6764 [vitaly, Jeremy Kemper]
60 * Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper]
61 find(:all, :conditions => { :topic_id => [1, 2, 3], :last_read => nil }
63 * Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov]
65 * MySQL: detect when a NOT NULL column without a default value is misreported as default ''. Can't detect for string, text, and binary columns since '' is a legitimate default. #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper]
67 * validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz]
69 * Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen]
71 * Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, ray.fortna@jobster.com, Michael Schoen]
73 * Firebird: decimal/numeric support. #6408 [macrnic]
75 * Find with :include respects scoped :order. #5850
77 * Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes]
79 * Deprecation: object transactions warning. [Jeremy Kemper]
81 * has_one :dependent => :nullify ignores nil associates. #6528 [janovetz, Jeremy Kemper]
83 * Oracle: resolve test failures, use prefetched primary key for inserts, check for null defaults, fix limited id selection for eager loading. Factor out some common methods from all adapters. #6515 [Michael Schoen]
85 * Make add_column use the options hash with the Sqlite Adapter. Closes #6464 [obrie]
87 * Document other options available to migration's add_column. #6419 [grg]
89 * MySQL: all_hashes compatibility with old MysqlRes class. #6429, #6601 [Jeremy Kemper]
91 * Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney]
93 * fix select_limited_ids_list issues in postgresql, retain current behavior in other adapters [Rick]
95 * Restore eager condition interpolation, document it's differences [Rick]
97 * Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper]
99 * Add #delete support to has_many :through associations. Closes #6049 [Martin Landers]
101 * Reverted old select_limited_ids_list postgresql fix that caused issues in mysql. Closes #5851 [Rick]
103 * Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com]
105 * Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com]
107 * Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan]
109 * Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [BobSilva]
111 * The has_many create method works with polymorphic associations. #6361 [Dan Peterson]
113 * MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes]
115 * save! shouldn't validate twice. #6324 [maiha, Bob Silva]
117 * Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. #1887, #5780 [Michael Schuerig]
119 * Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson]
121 * Deprecation: count class method should be called with an options hash rather than two args for conditions and joins. #6287 [Bob Silva]
123 * has_one associations with a nil target may be safely marshaled. #6279 [norbauer, Jeremy Kemper]
125 * Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Koz]
127 * Add a :namespace option to AR::Base#to_xml [Koz]
129 * Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper]
131 * Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson]
133 * Improve yaml fixtures error reporting. #6205 [Bruce Williams]
135 * Rename AR::Base#quote so people can use that name in their models. #3628 [Koz]
137 * Add deprecation warning for inferred foreign key. #6029 [Josh Susser]
139 * Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com]
141 * Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser]
143 * Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward]
145 * to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher]
147 * has_many :through conditions are sanitized by the associating class. #5971 [martin.emde@gmail.com]
149 * Fix spurious newlines and spaces in AR::Base#to_xml output [Jamis Buck]
151 * has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. #5927 [Chris Mear, Jonathan Viney]
153 * Nested subclasses are not prefixed with the parent class' table_name since they should always use the base class' table_name. #5911 [Jonathan Viney]
155 * SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi]
157 * Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark]
159 * Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com]
161 * Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com]
163 * MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward]
165 * to_xml: correct naming of included associations. #5831 [josh.starcher@gmail.com]
167 * Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [josh@hasmanythrough.com]
169 * Add records to has_many :through using <<, push, and concat by creating the association record. Raise if base or associate are new records since both ids are required to create the association. #build raises since you can't associate an unsaved record. #create! takes an attributes hash and creates the associated record and its association in a transaction. [Jeremy Kemper]
171 # Create a tagging to associate the post and tag.
172 post.tags << Tag.find_by_name('old')
173 post.tags.create! :name => 'general'
176 post.taggings.create!(:tag => Tag.find_by_name('finally')
178 post.taggings.create!(:tag => Tag.create!(:name => 'general'))
181 * Cache nil results for :included has_one associations also. #5787 [Michael Schoen]
183 * Fixed a bug which would cause .save to fail after trying to access a empty has_one association on a unsaved record. [Tobias Luetke]
185 * Nested classes are given table names prefixed by the singular form of the parent's table name. [Jeremy Kemper]
186 Example: Invoice::Lineitem is given table name invoice_lineitems
188 * Migrations: uniquely name multicolumn indexes so you don't have to. [Jeremy Kemper]
189 # people_active_last_name_index, people_active_deactivated_at_index
190 add_index :people, [:active, :last_name]
191 add_index :people, [:active, :deactivated_at]
192 remove_index :people, [:active, :last_name]
193 remove_index :people, [:active, :deactivated_at]
195 WARNING: backward-incompatibility. Multicolumn indexes created before this
196 revision were named using the first column name only. Now they're uniquely
197 named using all indexed columns.
199 To remove an old multicolumn index, remove_index :table_name, :first_column
201 * Fix for deep includes on the same association. [richcollins@gmail.com]
203 * Tweak fixtures so they don't try to use a non-ActiveRecord class. [Kevin Clark]
205 * Remove ActiveRecord::Base.reset since Dispatcher doesn't use it anymore. [Rick Olson]
207 * PostgreSQL: autodetected sequences work correctly with multiple schemas. Rely on the schema search_path instead of explicitly qualifying the sequence name with its schema. #5280 [guy.naor@famundo.com]
209 * Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
211 * Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael A. Schoen]
213 * Don't save has_one associations unnecessarily. #5735 [Jonathan Viney]
215 * Refactor ActiveRecord::Base.reset_subclasses to #reset, and add global observer resetting. [Rick Olson]
217 * Formally deprecate the deprecated finders. [Koz]
219 * Formally deprecate rich associations. [Koz]
221 * Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com]
223 * Fix announcement of very long migration names. #5722 [blake@near-time.com]
225 * The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com]
227 * Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com]
229 * Added support for conditions on Base.exists? #5689 [josh@joshpeek.com]. Examples:
231 assert (Topic.exists?(:author_name => "David"))
232 assert (Topic.exists?(:author_name => "Mary", :approved => true))
233 assert (Topic.exists?(["parent_id = ?", 1]))
235 * Schema dumper quotes date :default values. [Dave Thomas]
237 * Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson]
239 * Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper]
241 * Patch sql injection vulnerability when using integer or float columns. [Jamis Buck]
243 * Allow #count through a has_many association to accept :include. [Dan Peterson]
245 * create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw]
247 * PostgreSQL: return array fields as strings. #4664 [Robby Russell]
249 * SQLServer: added tests to ensure all database statements are closed, refactored identity_insert management code to use blocks, removed update/delete rowcount code out of execute and into update/delete, changed insert to go through execute method, removed unused quoting methods, disabled pessimistic locking tests as feature is currently unsupported, fixed RakeFile to load sqlserver specific tests whether running in ado or odbc mode, fixed support for recently added decimal types, added support for limits on integer types. #5670 [Tom Ward]
251 * SQLServer: fix db:schema:dump case-sensitivity. #4684 [Will Rogers]
253 * Oracle: BigDecimal support. #5667 [schoenm@earthlink.net]
255 * Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. #5454 [robbat2@gentoo.org, work@ashleymoran.me.uk]
257 * Firebird migrations support. #5337 [Ken Kunz <kennethkunz@gmail.com>]
259 * PostgreSQL: create/drop as postgres user. #4790 [mail@matthewpainter.co.uk, mlaster@metavillage.com]
261 * PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net]
263 * PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com]
265 * Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net]
267 * Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [schoenm@earthlink.net]
269 * Fixed a few Oracle issues: Allows Oracle's odd date handling to still work consistently within #to_xml, Passes test that hardcode insert statement by dropping the :id column, Updated RUNNING_UNIT_TESTS with Oracle instructions, Corrects method signature for #exec #5294 [schoenm@earthlink.net]
271 * Added :group to available options for finds done on associations #5516 [mike@michaeldewey.org]
273 * Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au]
275 * Removed deprecated timestamps_gmt class methods. [Jeremy Kemper]
277 * rake build_mysql_database grants permissions to rails@localhost. #5501 [brianegge@yahoo.com]
279 * PostgreSQL: support microsecond time resolution. #5492 [alex@msgpad.com]
281 * Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum.
283 * Added find_or_initialize_by_X which works like find_or_create_by_X but doesn't save the newly instantiated record. [Sam Stephenson]
285 * Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock! method to obtain a row lock on a single record (reloads the record with :lock => true). [Shugo Maeda]
286 # Obtain an exclusive lock on person 1 so we can safely increment visits.
287 Person.transaction do
288 # select * from people where id=1 for update
289 person = Person.find(1, :lock => true)
294 * PostgreSQL: introduce allow_concurrency option which determines whether to use blocking or asynchronous #execute. Adapters with blocking #execute will deadlock Ruby threads. The default value is ActiveRecord::Base.allow_concurrency. [Jeremy Kemper]
296 * Use a per-thread (rather than global) transaction mutex so you may execute concurrent transactions on separate connections. [Jeremy Kemper]
298 * Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar]
300 * Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de)
302 * Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [DHH]
304 * Added simple hash conditions to find that'll just convert hash to an AND-based condition string #5143 [hcatlin@gmail.com]. Example:
306 Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2)
310 Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2)
312 This makes it easier to pass in the options from a form or otherwise outside.
315 * Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com]
317 * Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net]
319 * Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com]
321 * Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com]
323 * Fixed that count distinct should use the selected column even when using :include #5251 [anna@wota.jp]
325 * Fixed that :includes merged from with_scope won't cause the same association to be loaded more than once if repetition occurs in the clauses #5253 [alex@purefiction.net]
327 * Allow models to override to_xml. #4989 [Blair Zajac <blair@orcaware.com>]
329 * PostgreSQL: don't ignore port when host is nil since it's often used to label the domain socket. #5247 [shimbo@is.naist.jp]
331 * Records and arrays of records are bound as quoted ids. [Jeremy Kemper]
332 Foo.find(:all, :conditions => ['bar_id IN (?)', bars])
333 Foo.find(:first, :conditions => ['bar_id = ?', bar])
335 * Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [DHH]
337 * Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick]
339 * Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [josh@hasmanythrough.com]
341 * Provide Association Extensions access to the instance that the association is being accessed from.
342 Closes #4433 [josh@hasmanythrough.com]
344 * Update OpenBase adaterp's maintainer's email address. Closes #5176. [Derrick Spell]
346 * Add a quick note about :select and eagerly included associations. [Rick]
348 * Add docs for the :as option in has_one associations. Closes #5144 [cdcarter@gmail.com]
350 * Fixed that has_many collections shouldn't load the entire association to do build or create [DHH]
352 * Added :allow_nil option for aggregations #5091 [ian.w.white@gmail.com]
354 * Fix Oracle boolean support and tests. Closes #5139. [schoenm@earthlink.net]
356 * create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper]
358 * Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com]
360 * Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk]
362 * PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. #2900 [keegan@thebasement.org]
364 * Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com]
366 * Allow :uniq => true with has_many :through associations. [Jeremy Kemper]
368 * Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.]
370 * Allow AR::Base#to_xml to include methods too. Closes #4921. [johan@textdrive.com]
372 * Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>]
374 * When grouping, use the appropriate option key. [Marcel Molina Jr.]
376 * Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com]
378 * Add warning about the proper way to validate the presence of a foreign key. Closes #4147. [Francois Beausoleil <francois.beausoleil@gmail.com>]
380 * Fix syntax error in documentation. Closes #4679. [mislav@nippur.irb.hr]
382 * Add Oracle support for CLOB inserts. Closes #4748. [schoenm@earthlink.net sandra.metz@duke.edu]
384 * Various fixes for sqlserver_adapter (odbc statement finishing, ado schema dumper, drop index). Closes #4831. [kajism@yahoo.com]
386 * Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net]
388 * Prettify output of schema_dumper by making things line up. Closes #4241 [Caio Chassot <caio@v2studio.com>]
390 * Make build_postgresql_databases task make databases owned by the postgres user. Closes #4790. [mlaster@metavillage.com]
392 * Sybase Adapter type conversion cleanup. Closes #4736. [dev@metacasa.net]
394 * Fix bug where calculations with long alias names return null. [Rick]
396 * Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick]
398 @post.tags << @tag # BAD
399 @post.taggings.create(:tag => @tag) # GOOD
401 * Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick]
403 * Add ActiveRecord::Errors#to_xml [Jamis Buck]
405 * Properly quote index names in migrations (closes #4764) [John Long]
407 * Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick]
409 * Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick]
411 * Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick]
413 * Add :case_sensitive option to validates_uniqueness_of (closes #3090) [Rick]
415 class Account < ActiveRecord::Base
416 validates_uniqueness_of :email, :case_sensitive => false
419 * Allow multiple association extensions with :extend option (closes #4666) [Josh Susser]
421 class Account < ActiveRecord::Base
422 has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension]
426 *1.14.4* (August 8th, 2006)
428 * Add warning about the proper way to validate the presence of a foreign key. #4147 [Francois Beausoleil <francois.beausoleil@gmail.com>]
430 * Fix syntax error in documentation. #4679 [mislav@nippur.irb.hr]
432 * Update inconsistent migrations documentation. #4683 [machomagna@gmail.com]
435 *1.14.3* (June 27th, 2006)
437 * Fix announcement of very long migration names. #5722 [blake@near-time.com]
439 * Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>]
441 * Properly quote index names in migrations (closes #4764) [John Long]
443 * Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick]
445 * Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick]
448 *1.14.2* (April 9th, 2006)
450 * Fixed calculations for the Oracle Adapter (closes #4626) [Michael Schoen]
453 *1.14.1* (April 6th, 2006)
455 * Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar]
457 * Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind]
459 * Enable Limit/Offset in Calculations (closes #4558) [lmarlow@yahoo.com]
461 * Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick]
463 * Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr]
465 * Allow AR::Base#respond_to? to behave when @attributes is nil [zenspider]
467 * Support eager includes when going through a polymorphic has_many association. [Rick]
469 * Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick]
471 class Post < ActiveRecord::Base
472 has_one :tagging, :as => :taggable
475 Post.find :all, :include => :tagging
477 * Added descriptive error messages for invalid has_many :through associations: going through :has_one or :has_and_belongs_to_many [Rick]
479 * Added support for going through a polymorphic has_many association: (closes #4401) [Rick]
481 class PhotoCollection < ActiveRecord::Base
482 has_many :photos, :as => :photographic
486 class Firm < ActiveRecord::Base
487 has_many :photo_collections
488 has_many :photos, :through => :photo_collections
491 * Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com]
493 * Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber]
495 * Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan]
497 * Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick]
499 * DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [DHH]
501 * Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [DHH]
503 * Do not implicitly mark recordss of has_many :through as readonly but do mark habtm records as readonly (eventually only on join tables without rich attributes). [Marcel Mollina Jr.]
505 * Fixed broken OCIAdapter #4457 [schoenm@earthlink.net]
508 *1.14.0* (March 27th, 2006)
510 * Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar]
512 * Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick]
514 * Add support for :include to with_scope [andrew@redlinesoftware.com]
516 * Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [schoenm@earthlink.net]
518 * Change periods (.) in table aliases to _'s. Closes #4251 [jeff@ministrycentered.com]
520 * Changed has_and_belongs_to_many join to INNER JOIN for Mysql 3.23.x. Closes #4348 [Rick]
522 * Fixed issue that kept :select options from being scoped [Rick]
524 * Fixed db_schema_import when binary types are present #3101 [DHH]
526 * Fixed that MySQL enums should always be returned as strings #3501 [DHH]
528 * Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson]
530 class Connection < ActiveRecord::Base
535 class Channel < ActiveRecord::Base
536 has_many :connections
537 has_many :contacts, :through => :connections, :class_name => 'User' # OLD
538 has_many :contacts, :through => :connections, :source => :user # NEW
541 * Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de]
543 * Allow overriding of find parameters in scoped has_many :through calls [Rick Olson]
545 In this example, :include => false disables the default eager association from loading. :select changes the standard
546 select clause. :joins specifies a join that is added to the end of the has_many :through query.
548 class Post < ActiveRecord::Base
549 has_many :tags, :through => :taggings, :include => :tagging do
550 def add_joins_and_select
551 find :all, :select => 'tags.*, authors.id as author_id', :include => false,
552 :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id'
557 * Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [DHH]
559 * Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [jonathan@bluewire.net.nz]
561 * Quit ignoring default :include options in has_many :through calls [Mark James]
563 * Allow has_many :through associations to find the source association by setting a custom class (closes #4307) [jonathan@bluewire.net.nz]
565 * Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson]
567 * Allow has_many :through to work on has_many associations (closes #3864) [sco@scottraymond.net] Example:
569 class Firm < ActiveRecord::Base
571 has_many :invoices, :through => :clients
574 class Client < ActiveRecord::Base
579 class Invoice < ActiveRecord::Base
583 * Raise error when trying to select many polymorphic objects with has_many :through or :include (closes #4226) [josh@hasmanythrough.com]
585 * Fixed has_many :through to include :conditions set on the :through association. closes #4020 [jonathan@bluewire.net.nz]
587 * Fix that has_many :through honors the foreign key set by the belongs_to association in the join model (closes #4259) [andylien@gmail.com / Rick]
589 * SQL Server adapter gets some love #4298 [rtomayko@gmail.com]
591 * Added OpenBase database adapter that builds on top of the http://www.spice-of-life.net/ruby-openbase/ driver. All functionality except LIMIT/OFFSET is supported #3528 [derrickspell@cdmplus.com]
593 * Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] #4108 Example (SpecialComment is using STI):
595 Author.find(:all, :include => { :posts => :special_comments }, :order => 'special_comments.body')
597 * Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick]
599 * Provide access to the underlying database connection through Adapter#raw_connection. Enables the use of db-specific methods without complicating the adapters. #2090 [Koz]
601 * Remove broken attempts at handling columns with a default of 'now()' in the postgresql adapter. #2257 [Koz]
603 * Added connection#current_database that'll return of the current database (only works in MySQL, SQL Server, and Oracle so far -- please help implement for the rest of the adapters) #3663 [Tom ward]
605 * Fixed that Migration#execute would have the table name prefix appended to its query #4110 [mark.imbriaco@pobox.com]
607 * Make all tinyint(1) variants act like boolean in mysql (tinyint(1) unsigned, etc.) [Jamis Buck]
609 * Use association's :conditions when eager loading. [jeremyevans0@gmail.com] #4144
611 * Alias the has_and_belongs_to_many join table on eager includes. #4106 [jeremyevans0@gmail.com]
613 This statement would normally error because the projects_developers table is joined twice, and therefore joined_on would be ambiguous.
615 Developer.find(:all, :include => {:projects => :developers}, :conditions => 'join_project_developers.joined_on IS NOT NULL')
617 * Oracle adapter gets some love #4230 [schoenm@earthlink.net]
619 * Changes :text to CLOB rather than BLOB [Moses Hohman]
620 * Fixes an issue with nil numeric length/scales (several)
621 * Implements support for XMLTYPE columns [wilig / Kubo Takehiro]
622 * Tweaks a unit test to get it all green again
623 * Adds support for #current_database
625 * Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson]
627 class CachedModel < ActiveRecord::Base
628 self.abstract_class = true
631 class Post < CachedModel
634 CachedModel.abstract_class?
646 * Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson]
648 class Foo < ActiveRecord::Base
649 has_many :attachments, :as => :attachable, :dependent => :delete_all
652 * Nicer error message on has_many :through when :through reflection can not be found. #4042 [court3nay@gmail.com]
654 * Upgrade to Transaction::Simple 1.3 [Jamis Buck]
656 * Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson]
658 * Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com]
660 * Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com]
662 * Dynamically set allow_concurrency. #4044 [Stefan Kaes]
664 * Added Base#to_xml that'll turn the current record into a XML representation [DHH]. Example:
670 <?xml version="1.0" encoding="UTF-8"?>
672 <title>The First Topic</title>
673 <author-name>David</author-name>
674 <id type="integer">1</id>
675 <approved type="boolean">false</approved>
676 <replies-count type="integer">0</replies-count>
677 <bonus-time type="datetime">2000-01-01 08:28:00</bonus-time>
678 <written-on type="datetime">2003-07-16 09:28:00</written-on>
679 <content>Have a nice day</content>
680 <author-email-address>david@loudthinking.com</author-email-address>
681 <parent-id></parent-id>
682 <last-read type="date">2004-04-15</last-read>
685 ...and you can configure with:
687 topic.to_xml(:skip_instruct => true, :except => [ :id, bonus_time, :written_on, replies_count ])
692 <title>The First Topic</title>
693 <author-name>David</author-name>
694 <approved type="boolean">false</approved>
695 <content>Have a nice day</content>
696 <author-email-address>david@loudthinking.com</author-email-address>
697 <parent-id></parent-id>
698 <last-read type="date">2004-04-15</last-read>
701 You can even do load first-level associations as part of the document:
703 firm.to_xml :include => [ :account, :clients ]
705 ...that'll return something like:
707 <?xml version="1.0" encoding="UTF-8"?>
709 <id type="integer">1</id>
710 <rating type="integer">1</rating>
711 <name>37signals</name>
714 <rating type="integer">1</rating>
718 <rating type="integer">1</rating>
719 <name>Microsoft</name>
723 <id type="integer">1</id>
724 <credit-limit type="integer">50</credit-limit>
728 * Allow :counter_cache to take a column name for custom counter cache columns [Jamis Buck]
730 * Documentation fixes for :dependent [robby@planetargon.com]
732 * Stop the MySQL adapter crashing when views are present. #3782 [Jonathan Viney]
734 * Don't classify the belongs_to class, it is already singular #4117 [keithm@infused.org]
736 * Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson]
738 * Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>]
740 * Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson]
742 * The first time a table is referenced in a join, no alias is used.
743 * After that, the parent class name and the reflection name are used.
745 Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ...
747 * Any additional join references get a numerical suffix like '_2', '_3', etc.
749 * Fixed eager loading problems with single-table inheritance #3580 [Rick Olson]. Post.find(:all, :include => :special_comments) now returns all posts, and any special comments that the posts may have. And made STI work with has_many :through and polymorphic belongs_to.
751 * Added cascading eager loading that allows for queries like Author.find(:all, :include=> { :posts=> :comments }), which will fetch all authors, their posts, and the comments belonging to those posts in a single query (using LEFT OUTER JOIN) #3913 [anna@wota.jp]. Examples:
753 # cascaded in two levels
754 >> Author.find(:all, :include=>{:posts=>:comments})
759 # cascaded in two levels and normal association
760 >> Author.find(:all, :include=>[{:posts=>:comments}, :categorizations])
766 # cascaded in two levels with two has_many associations
767 >> Author.find(:all, :include=>{:posts=>[:comments, :categorizations]})
773 # cascaded in three levels
774 >> Company.find(:all, :include=>{:groups=>{:members=>{:favorites}}})
780 * Make counter cache work when replacing an association #3245 [eugenol@gmail.com]
782 * Make migrations verbose [Jamis Buck]
784 * Make counter_cache work with polymorphic belongs_to [Jamis Buck]
786 * Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp]
788 * Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant (including migrations), but has the following caveats:
790 * Does not support DATE SQL column types; use DATETIME instead.
791 * Date columns on HABTM join tables are returned as String, not Time.
792 * Insertions are potentially broken for :polymorphic join tables
793 * BLOB column access not yet fully supported
795 * Clear stale, cached connections left behind by defunct threads. [Jeremy Kemper]
797 * CHANGED DEFAULT: set ActiveRecord::Base.allow_concurrency to false. Most AR usage is in single-threaded applications. [Jeremy Kemper]
799 * Renamed the "oci" adapter to "oracle", but kept the old name as an alias #4017 [schoenm@earthlink.net]
801 * Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's #1861, #2477 [DHH]
803 * Speed up class -> connection caching and stale connection verification. #3979 [Stefan Kaes]
805 * Add set_fixture_class to allow the use of table name accessors with models which use set_table_name. [Kevin Clark]
807 * Added that fixtures to placed in subdirectories of the main fixture files are also loaded #3937 [dblack@wobblini.net]
809 * Define attribute query methods to avoid method_missing calls. #3677 [jonathan@bluewire.net.nz]
811 * ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. #3591 [Simon Stapleton, Tom Ward]
813 * Added support for nested scopes #3407 [anna@wota.jp]. Examples:
815 Developer.with_scope(:find => { :conditions => "salary > 10000", :limit => 10 }) do
816 Developer.find(:all) # => SELECT * FROM developers WHERE (salary > 10000) LIMIT 10
818 # inner rule is used. (all previous parameters are ignored)
819 Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do
820 Developer.find(:all) # => SELECT * FROM developers WHERE (name = 'Jamis')
823 # parameters are merged
824 Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do
825 Developer.find(:all) # => SELECT * FROM developers WHERE (( salary > 10000 ) AND ( name = 'Jamis' )) LIMIT 10
829 * Fixed db2 connection with empty user_name and auth options #3622 [phurley@gmail.com]
831 * Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes #3699 [Masao Mutoh]
833 * Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [lars@pind.com]
835 * Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples:
840 Person.sum :salary, :group => :last_name
842 * Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) #3920 [contact@lukeredpath.co.uk]
844 * Reflections don't attempt to resolve module nesting of association classes. Simplify type computation. [Jeremy Kemper]
846 * Improved the Oracle OCI Adapter with better performance for column reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) #3879 [Aggregated by schoenm@earthlink.net]
848 * Fixed that the schema_info table used by ActiveRecord::Schema.define should respect table pre- and suffixes #3834 [rubyonrails@atyp.de]
850 * Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT #3839 [skaes]
852 * Correct syntax error in mysql DDL, and make AAACreateTablesTest run first [Bob Silva]
854 * Allow :include to be used with has_many :through associations #3611 [Michael Schoen]
856 * PostgreSQL: smarter schema dumps using pk_and_sequence_for(table). #2920 [Blair Zajac]
858 * SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward]
860 * Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson]
862 * PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org]
864 * Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark]
866 * ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Luetke]
868 * Using AssociationCollection#build with arrays of hashes should call build, not create [DHH]
870 * Remove definition of reloadable? from ActiveRecord::Base to make way for new Reloadable code. [Nicholas Seckar]
872 * Fixed schema handling for DB2 adapter that didn't work: an initial schema could be set, but it wasn't used when getting tables and indexes #3678 [Maik Schmidt]
874 * Support the :column option for remove_index with the PostgreSQL adapter. #3661 [shugo@ruby-lang.org]
876 * Add documentation for add_index and remove_index. #3600 [Manfred Stienstra <m.stienstra@fngtps.com>]
878 * If the OCI library is not available, raise an exception indicating as much. #3593 [schoenm@earthlink.net]
880 * Add explicit :order in finder tests as postgresql orders results differently by default. #3577. [Rick Olson]
882 * Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.]
884 * Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar]
886 * Make .count work for has_many associations with multi line finder sql [schoenm@earthlink.net]
888 * Add AR::Base.base_class for querying the ancestor AR::Base subclass [Jamis Buck]
890 * Allow configuration of the column used for optimistic locking [wilsonb@gmail.com]
892 * Don't hardcode 'id' in acts as list. [ror@philippeapril.com]
894 * Fix date errors for SQLServer in association tests. #3406 [kevin.clark@gmal.com]
896 * Escape database name in MySQL adapter when creating and dropping databases. #3409 [anna@wota.jp]
898 * Disambiguate table names for columns in validates_uniquness_of's WHERE clause. #3423 [alex.borovsky@gmail.com]
900 * .with_scope imposed create parameters now bypass attr_protected [Tobias Luetke]
902 * Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.]
904 * Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de]
906 * Sanitize scoped conditions. [Marcel Molina Jr.]
908 * Added option to Base.reflection_of_all_associations to specify a specific association to scope the call. For example Base.reflection_of_all_associations(:has_many) [DHH]
910 * Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [TobiasLuetke]
912 * SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [TobiasLuetke]
914 * Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber]
916 * Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron]
918 * removed :piggyback in favor of just allowing :select on :through associations. [Tobias Luetke]
920 * made method missing delegation to class methods on relation target work on :through associations. [Tobias Luetke]
922 * made .find() work on :through relations. [Tobias Luetke]
924 * Fix typo in association docs. #3296. [Blair Zajac]
926 * Fixed :through relations when using STI inherited classes would use the inherited class's name as foreign key on the join model [Tobias Luetke]
928 *1.13.2* (December 13th, 2005)
930 * Become part of Rails 1.0
932 * MySQL: allow encoding option for mysql.rb driver. [Jeremy Kemper]
934 * Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [DHH]. Example:
937 has_many :recent_comments, :class_name => "Comment", :limit => 10, :include => :author
940 post.recent_comments.find(:all) # Uses LIMIT 10 and includes authors
941 post.recent_comments.find(:all, :limit => nil) # Uses no limit but include authors
942 post.recent_comments.find(:all, :limit => nil, :include => nil) # Uses no limit and doesn't include authors
944 * Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [DHH]
946 * MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder]
948 * SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com]
950 * SQLServer: support uniqueidentifier columns. #2930 [keithm@infused.org]
952 * SQLServer: cope with tables names qualified by owner. #3067 [jeff@ministrycentered.com]
954 * SQLServer: cope with columns with "desc" in the name. #1950 [Ron Lusk, Ryan Tomayko]
956 * SQLServer: cope with primary keys with "select" in the name. #3057 [rdifrango@captechventures.com]
958 * Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen]
960 * MySQL: more robust test for nullified result hashes. #3124 [Stefan Kaes]
962 * Reloading an instance refreshes its aggregations as well as its associations. #3024 [François Beausolei]
964 * Fixed that using :include together with :conditions array in Base.find would cause NoMethodError #2887 [Paul Hammmond]
966 * PostgreSQL: more robust sequence name discovery. #3087 [Rick Olson]
968 * Oracle: use syntax compatible with Oracle 8. #3131 [Michael Schoen]
970 * MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper]
972 * Added preliminary support for polymorphic associations [DHH]
974 * Added preliminary support for join models [DHH]
976 * Allow validate_uniqueness_of to be scoped by more than just one column. #1559. [jeremy@jthopple.com, Marcel Molina Jr.]
978 * Firebird: active? and reconnect! methods for handling stale connections. #428 [Ken Kunz <kennethkunz@gmail.com>]
980 * Firebird: updated for FireRuby 0.4.0. #3009 [Ken Kunz <kennethkunz@gmail.com>]
982 * MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver. #428 [Jeremy Kemper]
984 * Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen]
986 * SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com]
988 * Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper]
990 * Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber, Michael Schoen]
992 * MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda]
994 * has_and_belongs_to_many: use JOIN instead of LEFT JOIN. [Jeremy Kemper]
996 * MySQL: introduce :encoding option to specify the character set for client, connection, and results. Only available for MySQL 4.1 and later with the mysql-ruby driver. Do SHOW CHARACTER SET in mysql client to see available encodings. #2975 [Shugo Maeda]
998 * Add tasks to create, drop and rebuild the MySQL and PostgreSQL test databases. [Marcel Molina Jr.]
1000 * Correct boolean handling in generated reader methods. #2945 [don.park@gmail.com, Stefan Kaes]
1002 * Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes]
1004 * Document :force option to create_table. #2921 [Blair Zajac <blair@orcaware.com>]
1006 * Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans]
1008 * Rename Version constant to VERSION. #2802 [Marcel Molina Jr.]
1010 * Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>]
1012 * SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
1014 * Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com]
1016 * SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
1018 * Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>]
1020 * Correct documentation for Base.delete_all. #1568 [Newhydra]
1022 * Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>]
1024 * Update documentation for Migrations. #2861 [Tom Werner <tom@cube6media.com>]
1026 * When AbstractAdapter#log rescues an exception, attempt to detect and reconnect to an inactive database connection. Connection adapter must respond to the active? and reconnect! instance methods. Initial support for PostgreSQL, MySQL, and SQLite. Make certain that all statements which may need reconnection are performed within a logged block: for example, this means no avoiding log(sql, name) { } if @logger.nil? #428 [Jeremy Kemper]
1028 * Oracle: Much faster column reflection. #2848 [Michael Schoen <schoenm@earthlink.net>]
1030 * Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing). Base.define_attr_method allows nil values. [Jeremy Kemper]
1032 * PostgreSQL: smarter sequence name defaults, stricter last_insert_id, warn on pk without sequence. [Jeremy Kemper]
1034 * PostgreSQL: correctly discover custom primary key sequences. #2594 [Blair Zajac <blair@orcaware.com>, meadow.nnick@gmail.com, Jeremy Kemper]
1036 * SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko]
1038 * Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>]
1040 * Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de]
1042 * Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>]
1044 * acts_as_list plays nicely with inheritance by remembering the class which declared it. #2811 [rephorm@rephorm.com]
1046 * Fix sqlite adaptor's detection of missing dbfile or database declaration. [Nicholas Seckar]
1048 * Fixed acts_as_list for definitions without an explicit :order #2803 [jonathan@bluewire.net.nz]
1050 * Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper]
1052 * Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.]
1054 * Correct whitespace problem in Oracle default column value parsing. #2788 [rick@rickbradley.com]
1056 * Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. #2065 [larrywilliams1@gmail.com, sam.kirchmeier@gmail.com, elliot@townx.org, Jeremy Kemper]
1058 * Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper]
1060 * More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>]
1063 *1.13.0* (November 7th, 2005)
1065 * Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko]
1067 * Added :include as an option for association declarations [DHH]. Example:
1069 has_many :posts, :include => [ :author, :comments ]
1071 * Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes. [Jeremy Kemper] Example:
1073 Comment.with_scope(:find => { :conditions => 'active=true' }, :create => { :post_id => 5 }) do
1074 # Find where name = ? and active=true
1075 Comment.find :all, :conditions => ['name = ?', name]
1076 # Create comment associated with :post_id
1077 Comment.create :body => "Hello world"
1080 * Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko]
1082 * Added constrain scoping for creates using a hash of attributes bound to the :creation key [DHH]. Example:
1084 Comment.constrain(:creation => { :post_id => 5 }) do
1085 # Associated with :post_id
1086 Comment.create :body => "Hello world"
1089 This is rarely used directly, but allows for find_or_create on associations. So you can do:
1091 # If the tag doesn't exist, a new one is created that's associated with the person
1092 person.tags.find_or_create_by_name("Summer")
1094 * Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [DHH]. Example:
1096 # No 'Summer' tag exists
1097 Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
1099 # Now the 'Summer' tag does exist
1100 Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
1102 * Added extension capabilities to has_many and has_and_belongs_to_many proxies [DHH]. Example:
1104 class Account < ActiveRecord::Base
1106 def find_or_create_by_name(name)
1107 first_name, *last_name = name.split
1108 last_name = last_name.join " "
1110 find_or_create_by_first_name_and_last_name(first_name, last_name)
1115 person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson")
1116 person.first_name # => "David"
1117 person.last_name # => "Heinemeier Hansson"
1119 Note that the anoymous module must be declared using brackets, not do/end (due to order of evaluation).
1121 * Omit internal dtproperties table from SQLServer table list. #2729 [rtomayko@gmail.com]
1123 * Quote column names in generated SQL. #2728 [rtomayko@gmail.com]
1125 * Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper]
1127 * Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper]
1129 * Correct fixture behavior when table name pluralization is off. #2719 [Rick Bradley <rick@rickbradley.com>]
1131 * Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson]
1133 * Added migration support for Oracle #2647 [Michael Schoen]
1135 * Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>]
1137 * Fixed SQL Server adapter to pass even more tests and do even better #2634 [rtomayko@gmail.com]
1139 * Fixed SQL Server adapter so it honors options[:conditions] when applying :limits #1978 [Tom Ward]
1141 * Added migration support to SQL Server adapter (please someone do the same for Oracle and DB2) #2625 [Tom Ward]
1143 * Use AR::Base.silence rather than AR::Base.logger.silence in fixtures to preserve Log4r compatibility. #2618 [dansketcher@gmail.com]
1145 * Constraints are cloned so they can't be inadvertently modified while they're
1146 in effect. Added :readonly finder constraint. Calling an association collection's class method (Part.foobar via item.parts.foobar) constrains :readonly => false since the collection's :joins constraint would otherwise force it to true. [Jeremy Kemper <rails@bitsweat.net>]
1148 * Added :offset and :limit to the kinds of options that Base.constrain can use #2466 [duane.johnson@gmail.com]
1150 * Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [schoenm@earthlink.net]
1152 * Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt]
1155 *1.12.2* (October 26th, 2005)
1157 * Allow symbols to rename columns when using SQLite adapter. #2531 [kevin.clark@gmail.com]
1159 * Map Active Record time to SQL TIME. #2575, #2576 [Robby Russell <robby@planetargon.com>]
1161 * Clarify semantics of ActiveRecord::Base#respond_to? #2560 [skaes@web.de]
1163 * Fixed Association#clear for associations which have not yet been accessed. #2524 [Patrick Lenz <patrick@lenz.sh>]
1165 * HABTM finders shouldn't return readonly records. #2525 [Patrick Lenz <patrick@lenz.sh>]
1167 * Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>]
1170 *1.12.1* (October 19th, 2005)
1172 * Always parenthesize :conditions options so they may be safely combined with STI and constraints.
1174 * Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com]
1176 * Added support for using limits in eager loads that involve has_many and has_and_belongs_to_many associations
1179 *1.12.0* (October 16th, 2005)
1181 * Update/clean up documentation (rdoc)
1183 * PostgreSQL sequence support. Use set_sequence_name in your model class to specify its primary key sequence. #2292 [Rick Olson <technoweenie@gmail.com>, Robby Russell <robby@planetargon.com>]
1185 * Change default logging colors to work on both white and black backgrounds. [Sam Stephenson]
1187 * YAML fixtures support ordered hashes for fixtures with foreign key dependencies in the same table. #1896 [purestorm@ggnore.net]
1189 * :dependent now accepts :nullify option. Sets the foreign key of the related objects to NULL instead of deleting them. #2015 [Robby Russell <robby@planetargon.com>]
1191 * Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around.
1193 * Avoid memleak in dev mode when using fcgi
1195 * Simplified .clear on active record associations by using the existing delete_records method. #1906 [Caleb <me@cpb.ca>]
1197 * Delegate access to a customized primary key to the conventional id method. #2444. [Blair Zajac <blair@orcaware.com>]
1199 * Fix errors caused by assigning a has-one or belongs-to property to itself
1201 * Add ActiveRecord::Base.schema_format setting which specifies how databases should be dumped [Sam Stephenson]
1203 * Update DB2 adapter. #2206. [contact@maik-schmidt.de]
1205 * Corrections to SQLServer native data types. #2267. [rails.20.clarry@spamgourmet.com]
1207 * Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency.
1209 * Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>]
1211 * Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code]
1213 * Add test coverage for content_columns. #2432. [coffee2code]
1215 * Speed up for unthreaded environments. #2431. [skaes@web.de]
1217 * Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [skaes@web.de]
1219 * Speed up the setting of table_name. #2428. [skaes@web.de]
1221 * Optimize instantiation of STI subclass records. In partial fullfilment of #1236. [skaes@web.de]
1223 * Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>]
1225 * Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [skaes@web.de]
1227 * Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>]
1229 * Add geometric type for postgresql adapter. #2233 [akaspick@gmail.com]
1231 * Add option (true by default) to generate reader methods for each attribute of a record to avoid the overhead of calling method missing. In partial fullfilment of #1236. [skaes@web.de]
1233 * Add convenience predicate methods on Column class. In partial fullfilment of #1236. [skaes@web.de]
1235 * Raise errors when invalid hash keys are passed to ActiveRecord::Base.find. #2363 [Chad Fowler <chad@chadfowler.com>, Nicholas Seckar]
1237 * Added :force option to create_table that'll try to drop the table if it already exists before creating
1239 * Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar]
1241 * Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>]
1243 * model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>]
1245 * Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman]
1247 * Recognize PostgreSQL NOW() default as equivalent to CURRENT_TIMESTAMP or CURRENT_DATE, depending on the column's type. #2256 [mat <mat@absolight.fr>]
1249 * Extensive documentation for the abstract database adapter. #2250 [François Beausoleil <fbeausoleil@ftml.net>]
1251 * Clean up Fixtures.reset_sequences for PostgreSQL. Handle tables with no rows and models with custom primary keys. #2174, #2183 [jay@jay.fm, Blair Zajac <blair@orcaware.com>]
1253 * Improve error message when nil is assigned to an attr which validates_size_of within a range. #2022 [Manuel Holtgrewe <purestorm@ggnore.net>]
1255 * Make update_attribute use the same writer method that update_attributes uses.
1256 #2237 [trevor@protocool.com]
1258 * Make migrations honor table name prefixes and suffixes. #2298 [Jakob S, Marcel Molina]
1260 * Correct and optimize PostgreSQL bytea escaping. #1745, #1837 [dave@cherryville.org, ken@miriamtech.com, bellis@deepthought.org]
1262 * Fixtures should only reset a PostgreSQL sequence if it corresponds to an integer primary key named id. #1749 [chris@chrisbrinker.com]
1264 * Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior)
1266 * Added new symbol-driven approach to activating observers with Base#observers= [DHH]. Example:
1268 ActiveRecord::Base.observers = :cacher, :garbage_collector
1270 * Added AbstractAdapter#select_value and AbstractAdapter#select_values as convenience methods for selecting single values, instead of hashes, of the first column in a SELECT #2283 [solo@gatelys.com]
1272 * Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck]
1274 * Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck]
1276 * Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, making it easier to consolidate large migration lists and port database schemas between databases. [Jamis Buck]
1278 * Fixed migrations for Windows when using more than 10 [David Naseby]
1280 * Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber]
1282 * Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Luetke]
1284 * Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar]
1286 * Fixed that Observers didn't observe sub-classes #627 [Florian Weber]
1288 * Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina]
1290 * Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 [skae]
1292 * Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber]
1294 * Added better exception error when unknown column types are used with migrations #1814 [fbeausoleil@ftml.net]
1296 * Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com]
1298 * Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg]
1300 * Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward]
1302 * Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code]
1304 * Fixed that Active Record would call SHOW FIELDS twice (or more) for the same model when the cached results were available #1947 [sd@notso.net]
1306 * Added log_level and use_silence parameter to ActiveRecord::Base.benchmark. The first controls at what level the benchmark statement will be logged (now as debug, instead of info) and the second that can be passed false to include all logging statements during the benchmark block/
1308 * Make sure the schema_info table is created before querying the current version #1903
1310 * Fixtures ignore table name prefix and suffix #1987 [Jakob S]
1312 * Add documentation for index_type argument to add_index method for migrations #2005 [blaine@odeo.com]
1314 * Modify read_attribute to allow a symbol argument #2024 [Ken Kunz]
1316 * Make destroy return self #1913 [sebastian.kanthak@muehlheim.de]
1318 * Fix typo in validations documentation #1938 [court3nay]
1320 * Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org]
1322 * Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky]
1324 * Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com]
1326 * Fix create_table so that id column is implicitly added [Rick Olson]
1328 * Default sequence names for Oracle changed to #{table_name}_seq, which is the most commonly used standard. In addition, a new method ActiveRecord::Base#set_sequence_name allows the developer to set the sequence name per model. This is a non-backwards-compatible change -- anyone using the old-style "rails_sequence" will need to either create new sequences, or set: ActiveRecord::Base.set_sequence_name = "rails_sequence" #1798
1330 * OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798
1332 * Fixed the handling of camelCase columns names in Oracle #1798
1334 * Implemented for OCI the Rakefile tasks of :clone_structure_to_test, :db_structure_dump, and :purge_test_database, which enable Oracle folks to enjoy all the agile goodness of Rails for testing. Note that the current implementation is fairly limited -- only tables and sequences are cloned, not constraints or indexes. A full clone in Oracle generally requires some manual effort, and is version-specific. Post 9i, Oracle recommends the use of the DBMS_METADATA package, though that approach requires editing of the physical characteristics generated #1798
1336 * Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798
1338 * Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Luetke]
1340 class Comment < AR:B
1342 find(:all, :conditions => ["body = ?", q])
1350 Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi'
1352 NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as
1353 by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on
1354 details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself
1357 * Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson]
1359 * Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar]
1361 * Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions
1363 * Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt]
1365 * Added :select option to find which can specify a different value than the default *, like find(:all, :select => "first_name, last_name"), if you either only want to select part of the columns or exclude columns otherwise included from a join #1338 [Stefan Kaes]
1368 *1.11.1* (11 July, 2005)
1370 * Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olsen]
1372 * Fixed that assume_bottom_position (in acts_as_list) could be called on items already last in the list and they would move one position away from the list #1648 [tyler@kianta.com]
1374 * Added ActiveRecord::Base.threaded_connections flag to turn off 1-connection per thread (required for thread safety). By default it's on, but WEBrick in Rails need it off #1685 [Sam Stephenson]
1376 * Correct reflected table name for singular associations. #1688 [court3nay@gmail.com]
1378 * Fixed optimistic locking with SQL Server #1660 [tom@popdog.net]
1380 * Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current
1382 * Added better error message for "packets out of order" #1630 [courtenay]
1384 * Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640
1387 *1.11.0* (6 July, 2005)
1389 * Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar]
1391 * Changed logging of SQL statements to use the DEBUG level instead of INFO
1393 * Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Luetke] See documentation under ActiveRecord::Migration and the additional support in the Rails rakefile/generator.
1395 * Added callback hooks to association collections #1549 [Florian Weber]. Example:
1398 has_and_belongs_to_many :developers, :before_add => :evaluate_velocity
1400 def evaluate_velocity(developer)
1405 ..raising an exception will cause the object not to be added (or removed, with before_remove).
1408 * Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry]
1410 * Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato]
1412 * Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber]
1414 * Speed up ActiveRecord#method_missing for the common case (read_attribute).
1416 * Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [skaes@web.de]
1418 * Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath]
1420 * Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at]
1422 * Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [michael@schuerig.de]
1424 * Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry]
1426 * Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry]
1428 * Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net]
1430 * Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl]
1432 * Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be:
1434 Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
1436 ...should instead be:
1440 :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
1441 :conditions => 'project_id=1'
1444 * Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina]
1446 * Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon]
1448 * Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379
1450 * Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid]
1452 * Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice
1454 * Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper]
1456 * Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak].
1459 david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")]
1462 If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new
1463 project is saved when david.save is called.
1465 Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do:
1467 david.project_ids = [1, 5, 7]
1469 * Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com]
1471 * Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Luetke]
1473 * Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org]
1475 * Corrected @@configurations typo #1410 [david@ruppconsulting.com]
1477 * Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com]
1479 * Allow before/after update hooks to work on models using optimistic locking
1481 * Eager loading of dependent has_one associations won't delete the association #1212
1483 * Added a second parameter to the build and create method for has_one that controls whether the existing association should be replaced (which means nullifying its foreign key as well). By default this is true, but false can be passed to prevent it.
1485 * Using transactional fixtures now causes the data to be loaded only once.
1487 * Added fixture accessor methods that can be used when instantiated fixtures are disabled.
1492 assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
1495 * Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar]
1497 * Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar]
1499 * CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309
1501 * Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead
1503 * Added the :if option to all validations that can either use a block or a method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny]. Examples:
1505 Conditional validations such as the following are made possible:
1506 validates_numericality_of :income, :if => :employed?
1508 Conditional validations can also solve the salted login generator problem:
1509 validates_confirmation_of :password, :if => :new_password?
1512 validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 }
1514 * Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
1516 * Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
1518 * Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper]
1520 * Changed that destroying an object will only freeze the attributes hash, which keeps the object from having attributes changed (as that wouldn't make sense), but allows for the querying of associations after it has been destroyed.
1522 * Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first.
1524 * Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example:
1526 # SELECT * FROM topics WHERE title IN ('First', 'Second')
1527 Topic.find_all_by_title(["First", "Second"])
1529 * Added compatibility with camelCase column names for dynamic finders #533 [Dee.Zsombor]
1531 * Fixed extraneous comma in count() function that made it not work with joins #1156 [jarkko/Dee.Zsombor]
1533 * Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid]
1535 * Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com]
1537 * Added encoding and min_messages options for PostgreSQL #1205 [shugo]. Configuration example:
1541 database: rails_development
1548 * Fixed acts_as_list where deleting an item that was removed from the list would ruin the positioning of other list items #1197 [Jamis Buck]
1550 * Added validates_exclusion_of as a negative of validates_inclusion_of
1552 * Optimized counting of has_many associations by setting the association to empty if the count is 0 so repeated calls doesn't trigger database calls
1555 *1.10.1* (20th April, 2005)
1557 * Fixed frivilous database queries being triggered with eager loading on empty associations and other things
1559 * Fixed order of loading in eager associations
1561 * Fixed stray comma when using eager loading and ordering together from has_many associations #1143
1564 *1.10.0* (19th April, 2005)
1566 * Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example:
1568 for post in Post.find(:all, :limit => 100)
1569 puts "Post: " + post.title
1570 puts "Written by: " + post.author.name
1571 puts "Last comment on: " + post.comments.first.created_on
1574 This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as:
1576 for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ])
1578 ...and the number of database queries needed is now 1.
1580 * Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples:
1582 Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC")
1583 Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC")
1584 Person.find(:first, :order => "created_on DESC", :offset => 5)
1585 Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
1586 Person.find(:all, :offset => 10, :limit => 10)
1588 * Added acts_as_nested_set #1000 [wschenk]. Introduction:
1590 This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with
1591 the added feature that you can select the children and all of it's descendants with
1592 a single query. A good use case for this is a threaded post system, where you want
1593 to display every reply to a comment without multiple selects.
1595 * Added Base.save! that attempts to save the record just like Base.save but will raise a RecordInvalid exception instead of returning false if the record is not valid [After much pestering from Dave Thomas]
1597 * Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com]
1599 * Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com]
1601 * Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com]
1603 * Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher]
1605 * Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle]
1607 * Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com]
1609 * Added insert_at(position) to acts_as_list #1083 [DeLynnB]
1611 * Removed the default order by id on has_and_belongs_to_many queries as it could kill performance on large sets (you can still specify by hand with :order)
1613 * Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com]
1615 * Fixed boolean saving on Oracle #1093 [mparrish@pearware.org]
1617 * Moved build_association and create_association for has_one and belongs_to out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864
1619 * Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt]
1621 * Added quoting of column names for fixtures #997 [jcfischer@gmail.com]
1623 * Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis]
1625 * Fixed that benchmarking times for rendering included db runtimes #987 [skaes@web.de]
1627 * Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org]
1629 * Added that model.items.delete(child) will delete the child, not just set the foreign key to nil, if the child is dependent on the model #978 [Jeremy Kemper]
1631 * Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org]
1633 * Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de]
1635 * Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de]
1637 * Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas]
1639 * Renamed DateHelper#distance_of_time_in_words_to_now to DateHelper#time_ago_in_words (old method name is still available as a deprecated alias)
1642 *1.9.1* (27th March, 2005)
1644 * Fixed that Active Record objects with float attribute could not be cloned #808
1646 * Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar]
1648 * Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count
1650 * Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron]
1652 * Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb]
1655 *1.9.0* (22th March, 2005)
1657 * Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]. Example:
1659 Developer.find_all nil, 'id ASC', 5 # return the first five developers
1660 Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward
1662 This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged.
1664 * Added alias_method :to_param, :id to Base, such that Active Record objects to be used as URL parameters in Action Pack automatically #812 [Nicholas Seckar/Sam Stephenson]
1666 * Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins]
1668 * Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org]
1670 * Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel]
1672 * Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid]
1674 * Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com]
1676 * Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net]
1678 * Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak]
1680 * Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak]
1682 * Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm]
1684 * Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself
1686 * Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body)
1689 *1.8.0* (7th March, 2005)
1691 * Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default)
1693 * Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron]
1695 * Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation:
1697 * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the
1698 +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+
1699 objects that should be inspected to determine which attributes triggered the errors.
1700 * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method.
1701 You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error.
1703 * Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k]
1705 * Added transactional fixtures that uses rollback to undo changes to fixtures instead of DELETE/INSERT -- it's much faster. See documentation under Fixtures #760 [Jeremy Kemper]
1707 * Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example:
1709 class Account < ActiveRecord::Base
1710 has_one :credit_card, :dependent => true
1712 class CreditCard < ActiveRecord::Base
1716 account.credit_card # => returns existing credit card, lets say id = 12
1717 account.credit_card = CreditCard.create("number" => "123")
1718 account.save # => CC with id = 12 is destroyed
1721 * Added validates_numericality_of #716 [skanthak/c.r.mcgrath]. Docuemntation:
1723 Validates whether the value of the specified attribute is numeric by trying to convert it to
1724 a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression
1725 <tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true).
1727 class Person < ActiveRecord::Base
1728 validates_numericality_of :value, :on => :create
1731 Configuration options:
1732 * <tt>message</tt> - A custom error message (default is: "is not a number")
1733 * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update)
1734 * <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false)
1737 * Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron]
1739 * Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed)
1741 * Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com]
1744 *1.7.0* (24th February, 2005)
1746 * Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck]
1748 * Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes:
1750 1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple
1751 and safe way of passing table-specific sequence information to the adapter.)
1752 2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to
1753 resort to some hacks to get data converted to Date or Time in Ruby.
1754 If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the
1755 hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time.
1756 This is nasty - but if you use Duck Typing you'll probably not care very much.
1757 In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is
1758 valid - too many databases use DATE for both.
1759 Timezones and sub-second precision on timestamps are not supported.
1760 3. Default values that are functions (such as "SYSDATE") are not supported. This is a
1761 restriction of the way active record supports default values.
1762 4. Referential integrity constraints are not fully supported. Under at least
1763 some circumstances, active record appears to delete parent and child records out of
1764 sequence and out of transaction scope. (Or this may just be a problem of test setup.)
1766 The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/
1768 * Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke]
1770 * Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm]
1772 * Fixed that when using validation macros with a custom message, if you happened to use single quotes in the message string you would get a parsing error #657 [tonka]
1774 * Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar]
1776 * Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com]
1778 * Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au]
1780 * Fixed that find_by_* would fail when column names had numbers #670 [demetrius]
1782 * Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn]
1784 1. Created a new columns method that is much cleaner.
1785 2. Corrected a problem with the select and select_all methods
1786 that didn't account for the LIMIT clause being passed into raw SQL statements.
1787 3. Implemented the string_to_time method in order to create proper instances of the time class.
1788 4. Added logic to the simplified_type method that allows the database to specify the scale of float data.
1789 5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string.
1791 * Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow@yahoo.com]
1793 * Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example:
1795 class Person < ActiveRecord::Base
1796 validates_each :first_name, :last_name do |record, attr|
1797 record.errors.add attr, 'starts with z.' if attr[0] == ?z
1801 * Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [Jeremy Kemper]
1803 * Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example:
1805 class Person < ActiveRecord::Base
1806 validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID }
1809 * Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates]
1811 * Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example:
1813 class Project < ActiveRecord::Base
1815 table_name "XYZ_PROJECT"
1816 inheritance_column { original_inheritance_column + "_id" }
1819 * Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu]
1822 *1.6.0* (January 25th, 2005)
1824 * Added that has_many association build and create methods can take arrays of record data like Base#create and Base#build to build/create multiple records at once.
1826 * Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336
1828 * Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once.
1830 * Added the option of supplying an array of ids and attributes to Base#update, so that multiple records can be updated at once (inspired by #526/Duane Johnson). Example
1832 people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
1833 Person.update(people.keys, people.values)
1835 * Added ActiveRecord::Base.timestamps_gmt that can be set to true to make the automated timestamping use GMT instead of local time #520 [Scott Baron]
1837 * Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat]
1839 * Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius]
1841 * Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper]
1843 * Added that has_and_belongs_to_many associations with additional attributes also can be created between unsaved objects and only committed to the database when Base#save is called on the associator #524 [Eric Anderson]
1845 * Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson]
1847 * Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not
1849 * Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription
1851 * Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius]
1853 * Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron]
1856 *1.5.1* (January 18th, 2005)
1858 * Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates]
1860 * Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle]
1863 *1.5.0* (January 17th, 2005)
1865 * Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel]
1867 * Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example:
1869 class Book < ActiveRecord::Base
1873 validates_associated :pages, :library
1876 * Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition:
1878 == Unsaved objects and associations
1880 You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be
1881 aware of, mostly involving the saving of associated objects.
1883 === One-to-one associations
1885 * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in
1886 order to update their primary keys - except if the parent object is unsaved (new_record? == true).
1887 * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment
1889 * If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below).
1890 * Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does
1891 not save the parent either.
1895 * Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object
1896 (the owner of the collection) is not yet stored in the database.
1897 * If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false.
1898 * You can add an object to a collection without automatically saving it by using the #collection.build method (documented below).
1899 * All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved.
1901 * Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates]
1903 * Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates]
1905 * Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates]
1907 * Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates]
1909 * Fixed binary support for PostgreSQL #444 [alex@byzantine.no]
1911 * Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the
1912 collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If
1913 it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards,
1914 it'll take one less SELECT query if you use length.
1916 * Added Base#attributes that returns a hash of all the attributes with their names as keys and clones of their objects as values #433 [atyp.de]
1918 * Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson]
1920 * Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey]
1922 * Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz]
1924 * Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper]
1926 * Added support for the new protocol spoken by MySQL 4.1.1+ servers for the Ruby/MySQL adapter that ships with Rails #440 [Matt Mower]
1928 * Added that Observers can use the observes class method instead of overwriting self.observed_class().
1931 class ListSweeper < ActiveRecord::Base
1932 def self.observed_class() [ List, Item ]
1936 class ListSweeper < ActiveRecord::Base
1940 * Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is
1942 * Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name
1944 * Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag.
1946 Before: topic.update_attribute(:approved, !approved?)
1947 After : topic.toggle!(:approved)
1949 * Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example:
1952 page.increment!(:views) # executes an UPDATE statement
1955 page.increment(:views).increment!(:views)
1958 * Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns.
1961 *1.4.0* (January 4th, 2005)
1963 * Added automated optimistic locking if the field <tt>lock_version</tt> is present. Each update to the
1964 record increments the lock_version column and the locking facilities ensure that records instantiated twice
1965 will let the last one saved raise a StaleObjectError if the first was also updated. Example:
1970 p1.first_name = "Michael"
1973 p2.first_name = "should fail"
1974 p2.save # Raises a ActiveRecord::StaleObjectError
1976 You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging,
1977 or otherwise apply the business logic needed to resolve the conflict.
1979 #384 [Michael Koziarski]
1981 * Added dynamic attribute-based finders as a cleaner way of getting objects by simple queries without turning to SQL.
1982 They work by appending the name of an attribute to <tt>find_by_</tt>, so you get finders like <tt>Person.find_by_user_name,
1983 Payment.find_by_transaction_id</tt>. So instead of writing <tt>Person.find_first(["user_name = ?", user_name])</tt>, you just do
1984 <tt>Person.find_by_user_name(user_name)</tt>.
1986 It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like
1987 <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing
1988 <tt>Person.find_first(["user_name = ? AND password = ?", user_name, password])</tt>, you just do
1989 <tt>Person.find_by_user_name_and_password(user_name, password)</tt>.
1991 While primarily a construct for easier find_firsts, it can also be used as a construct for find_all by using calls like
1992 <tt>Payment.find_all_by_amount(50)</tt> that is turned into <tt>Payment.find_all(["amount = ?", 50])</tt>. This is something not as equally useful,
1993 though, as it's not possible to specify the order in which the objects are returned.
1995 * Added block-style for callbacks #332 [Jeremy Kemper].
1998 before_destroy(Proc.new{ |record| Person.destroy_all "firm_id = #{record.id}" })
2001 before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" }
2003 * Added :counter_cache option to acts_as_tree that works just like the one you can define on belongs_to #371 [Josh]
2005 * Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates
2006 and times from the database. This is set to :local by default.
2008 * Added the possibility for adapters to overwrite add_limit! to implement a different limiting scheme than "LIMIT X" used by MySQL, PostgreSQL, and SQLite.
2010 * Added the possibility of having objects with acts_as_list created before their scope is available or...
2012 * Added a db2 adapter that only depends on the Ruby/DB2 bindings (http://raa.ruby-lang.org/project/ruby-db2/) #386 [Maik Schmidt]
2014 * Added the final touches to the Microsoft SQL Server adapter by Joey Gibson that makes it suitable for actual use #394 [DeLynn Barry]
2016 * Added that Base#find takes an optional options hash, including :conditions. Base#find_on_conditions deprecated in favor of #find with :conditions #407 [Jeremy Kemper]
2018 * Added HasManyAssociation#count that works like Base#count #413 [intinig]
2020 * Fixed handling of binary content in blobs and similar fields for Ruby/MySQL and SQLite #409 [xal]
2022 * Fixed a bug in the Ruby/MySQL that caused binary content to be escaped badly and come back mangled #405 [Tobias Luetke]
2024 * Fixed that the const_missing autoload assumes the requested constant is set by require_association and calls const_get to retrieve it.
2025 If require_association did not set the constant then const_get will call const_missing, resulting in an infinite loop #380 [Jeremy Kemper]
2027 * Fixed broken transactions that were actually only running object-level and not db level transactions [andreas]
2029 * Fixed that validates_uniqueness_of used 'id' instead of defined primary key #406
2031 * Fixed that the overwritten respond_to? method didn't take two parameters like the original #391
2033 * Fixed quoting in validates_format_of that would allow some rules to pass regardless of input #390 [Dmitry V. Sabanin]
2036 *1.3.0* (December 23, 2004)
2038 * Added a require_association hook on const_missing that makes it possible to use any model class without requiring it first. This makes STI look like:
2041 require_association 'person'
2042 class Employee < Person
2046 class Employee < Person
2049 This also reduces the usefulness of Controller.model in Action Pack to currently only being for documentation purposes.
2051 * Added that Base.update_all and Base.delete_all return an integer of the number of affected rows #341
2053 * Added scope option to validation_uniqueness #349 [Kent Sibilev]
2055 * Added respondence to *_before_type_cast for all attributes to return their string-state before they were type casted by the column type.
2056 This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100".
2058 * Added allow_nil options to validates_inclusion_of so that validation is only triggered if the attribute is not nil [what-a-day]
2060 * Added work-around for PostgreSQL and the problem of getting fixtures to be created from id 1 on each test case.
2061 This only works for auto-incrementing primary keys called "id" for now #359 [Scott Baron]
2063 * Added Base#clear_association_cache to empty all the cached associations #347 [Tobias Luetke]
2065 * Added more informative exceptions in establish_connection #356 [Jeremy Kemper]
2067 * Added Base#update_attributes that'll accept a hash of attributes and save the record (returning true if it passed validation, false otherwise).
2070 person.attributes = @params["person"]
2074 person.update_attributes(@params["person"])
2076 * Added Base.destroy and Base.delete to remove records without holding a reference to them first.
2078 * Added that query benchmarking will only happen if its going to be logged anyway #344
2080 * Added higher_item and lower_item as public methods for acts_as_list #342 [Tobias Luetke]
2082 * Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [Jeremy Kemper]
2084 * Fixed that overriding an attribute's accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used
2085 the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten]
2087 * Fixed that Base.table_name would expect a parameter when used in has_and_belongs_to_many joins [Anna Lissa Cruz]
2089 * Fixed that nested transactions now work by letting the outer most transaction have the responsibilty of starting and rolling back the transaction.
2090 If any of the inner transactions swallow the exception raised, though, the transaction will not be rolled back. So always let the transaction
2091 bubble up even when you've dealt with local issues. Closes #231 and #340.
2093 * Fixed validates_{confirmation,acceptance}_of to only happen when the virtual attributes are not nil #348 [dpiddy@gmail.com]
2095 * Changed the interface on AbstractAdapter to require that adapters return the number of affected rows on delete and update operations.
2097 * Fixed the automated timestamping feature when running under Rails' development environment that resets the inheritable attributes on each request.
2103 * Added Base.validates_inclusion_of that validates whether the value of the specified attribute is available in a particular enumerable
2104 object. [what-a-day]
2106 class Person < ActiveRecord::Base
2107 validates_inclusion_of :gender, :in=>%w( m f ), :message=>"woah! what are you then!??!!"
2108 validates_inclusion_of :age, :in=>0..99
2111 * Added acts_as_list that can decorates an existing class with methods like move_higher/lower, move_to_top/bottom. [Tobias Luetke] Example:
2113 class TodoItem < ActiveRecord::Base
2114 acts_as_list :scope => :todo_list_id
2115 belongs_to :todo_list
2118 * Added acts_as_tree that can decorates an existing class with a many to many relationship with itself. Perfect for categories in
2119 categories and the likes. [Tobias Luetke]
2121 * Added that Active Records will automatically record creation and/or update timestamps of database objects if fields of the names
2122 created_at/created_on or updated_at/updated_on are present. [Tobias Luetke]
2124 * Added Base.default_error_messages as a hash of all the error messages used in the validates_*_of so they can be changed in one place [Tobias Luetke]
2126 * Added automatic transaction block around AssociationCollection.<<, AssociationCollection.delete, and AssociationCollection.destroy_all
2128 * Fixed that Base#find will return an array if given an array -- regardless of the number of elements #270 [Marten]
2130 * Fixed that has_and_belongs_to_many would generate bad sql when naming conventions differed from using vanilla "id" everywhere [RedTerror]
2132 * Added a better exception for when a type column is used in a table without the intention of triggering single-table inheritance. Example:
2134 ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'bad_class!'.
2135 This error is raised because the column 'type' is reserved for storing the class in case of inheritance.
2136 Please rename this column if you didn't intend it to be used for storing the inheritance class or
2137 overwrite Company.inheritance_column to use another column for that information.
2139 * Added that single-table inheritance will only kick in if the inheritance_column (by default "type") is present. Otherwise, inheritance won't
2140 have any magic side effects.
2142 * Added the possibility of marking fields as being in error without adding a message (using nil) to it that'll get displayed wth full_messages #208 [mjobin]
2144 * Fixed Base.errors to be indifferent as to whether strings or symbols are used. Examples:
2147 errors.add(:name, "must be shorter") if name.size > 10
2148 errors.on(:name) # => "must be shorter"
2149 errors.on("name") # => nil
2152 errors.add(:name, "must be shorter") if name.size > 10
2153 errors.on(:name) # => "must be shorter"
2154 errors.on("name") # => "must be shorter"
2156 * Added Base.validates_format_of that Validates whether the value of the specified attribute is of the correct form by matching
2157 it against the regular expression provided. [Marcel]
2159 class Person < ActiveRecord::Base
2160 validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :on => :create
2163 * Added Base.validates_length_of that delegates to add_on_boundary_breaking #312 [Tobias Luetke]. Example:
2165 Validates that the specified attribute matches the length restrictions supplied in either:
2167 - configuration[:minimum]
2168 - configuration[:maximum]
2169 - configuration[:is]
2170 - configuration[:within] (aka. configuration[:in])
2172 Only one option can be used at a time.
2174 class Person < ActiveRecord::Base
2175 validates_length_of :first_name, :maximum=>30
2176 validates_length_of :last_name, :maximum=>30, :message=>"less than %d if you don't mind"
2177 validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name"
2178 validates_length_of :fav_bra_size, :minimum=>1, :too_short=>"please enter at least %d character"
2179 validates_length_of :smurf_leader, :is=>4, :message=>"papa is spelled with %d characters... don't play me."
2182 * Added Base.validate_presence as an alternative to implementing validate and doing errors.add_on_empty yourself.
2184 * Added Base.validates_uniqueness_of that alidates whether the value of the specified attributes are unique across the system.
2185 Useful for making sure that only one user can be named "davidhh".
2187 class Person < ActiveRecord::Base
2188 validates_uniqueness_of :user_name
2191 When the record is created, a check is performed to make sure that no record exist in the database with the given value for the specified
2192 attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself.
2195 * Added Base.validates_confirmation_of that encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example:
2198 class Person < ActiveRecord::Base
2199 validates_confirmation_of :password
2203 <%= password_field "person", "password" %>
2204 <%= password_field "person", "password_confirmation" %>
2206 The person has to already have a password attribute (a column in the people table), but the password_confirmation is virtual.
2207 It exists only as an in-memory variable for validating the password. This check is performed both on create and update.
2210 * Added Base.validates_acceptance_of that encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example:
2212 class Person < ActiveRecord::Base
2213 validates_acceptance_of :terms_of_service
2216 The terms_of_service attribute is entirely virtual. No database column is needed. This check is performed both on create and update.
2218 NOTE: The agreement is considered valid if it's set to the string "1". This makes it easy to relate it to an HTML checkbox.
2221 * Added validation macros to make the stackable just like the lifecycle callbacks. Examples:
2223 class Person < ActiveRecord::Base
2224 validate { |record| record.errors.add("name", "too short") unless name.size > 10 }
2225 validate { |record| record.errors.add("name", "too long") unless name.size < 20 }
2226 validate_on_create :validate_password
2229 def validate_password
2230 errors.add("password", "too short") unless password.size > 6
2234 * Added the option for sanitizing find_by_sql and the offset parts in regular finds [Sam Stephenson]. Examples:
2236 Project.find_all ["category = ?", category_name], "created ASC", ["? OFFSET ?", 15, 20]
2237 Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]
2239 * Fixed value quoting in all generated SQL statements, so that integers are not surrounded in quotes and that all sanitation are happening
2240 through the database's own quoting routine. This should hopefully make it lots easier for new adapters that doesn't accept '1' for integer
2243 * Fixed has_and_belongs_to_many guessing of foreign key so that keys are generated correctly for models like SomeVerySpecialClient
2246 * Added counter_sql option for has_many associations [Jeremy Kemper]. Documentation:
2248 <tt>:counter_sql</tt> - specify a complete SQL statement to fetch the size of the association. If +:finder_sql+ is
2249 specified but +:counter_sql+, +:counter_sql+ will be generated by replacing SELECT ... FROM with SELECT COUNT(*) FROM.
2251 * Fixed that methods wrapped in callbacks still return their original result #260 [Jeremy Kemper]
2253 * Fixed the Inflector to handle the movie/movies pair correctly #261 [Scott Baron]
2255 * Added named bind-style variable interpolation #281 [Michael Koziarski]. Example:
2257 Person.find(["id = :id and first_name = :first_name", { :id => 5, :first_name = "bob' or 1=1" }])
2259 * Added bind-style variable interpolation for the condition arrays that uses the adapter's quote method [Michael Koziarski]
2262 find_first([ "user_name = '%s' AND password = '%s'", user_name, password ])]
2263 find_first([ "firm_id = %s", firm_id ])] # unsafe!
2266 find_first([ "user_name = ? AND password = ?", user_name, password ])]
2267 find_first([ "firm_id = ?", firm_id ])]
2269 * Added CSV format for fixtures #272 [what-a-day]. (See the new and expanded documentation on fixtures for more information)
2271 * Fixed fixtures using primary key fields called something else than "id" [dave]
2273 * Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon]
2275 * Added reverse order of deleting fixtures, so referential keys can be maintained #247 [Tim Bates]
2277 * Added relative path search for sqlite dbfiles in database.yml (if RAILS_ROOT is defined) #233 [Jeremy Kemper]
2279 * Added option to establish_connection where you'll be able to leave out the parameter to have it use the RAILS_ENV environment variable
2281 * Fixed problems with primary keys and postgresql sequences (#230) [Tim Bates]
2283 * Added reloading for associations under cached environments like FastCGI and mod_ruby. This makes it possible to use those environments for development.
2284 This is turned on by default, but can be turned off with ActiveRecord::Base.reload_dependencies = false in production environments.
2286 NOTE: This will only have an effect if you let the associations manage the requiring of model classes. All libraries loaded through
2287 require will be "forever" cached. You can, however, use ActiveRecord::Base.load_or_require("library") to get this behavior outside of the
2288 auto-loading associations.
2290 * Added ERB capabilities to the fixture files for dynamic fixture generation. You don't need to do anything, just include ERB blocks like:
2300 <% for digit in 3..10 %>
2303 name: fixture_<%= digit %>
2306 * Changed the yaml fixture searcher to look in the root of the fixtures directory, so when you before could have something like:
2308 fixtures/developers/fixtures.yaml
2309 fixtures/accounts/fixtures.yaml
2311 ...you now need to do:
2313 fixtures/developers.yaml
2314 fixtures/accounts.yaml
2316 * Changed the fixture format from:
2321 name: David Heinemeier Hansson
2322 birthday: 1979-10-15
2323 profession: Systems development
2328 name: Steve Ross Kellock
2329 birthday: 1974-09-27
2330 profession: guy with keyboard
2336 name: David Heinemeier Hansson
2337 birthday: 1979-10-15
2338 profession: Systems development
2342 name: Steve Ross Kellock
2343 birthday: 1974-09-27
2344 profession: guy with keyboard
2346 The change is NOT backwards compatible. Fixtures written in the old YAML style needs to be rewritten!
2348 * All associations will now attempt to require the classes that they associate to. Relieving the need for most explicit 'require' statements.
2353 * Added automatic fixture setup and instance variable availability. Fixtures can also be automatically
2354 instantiated in instance variables relating to their names using the following style:
2356 class FixturesTest < Test::Unit::TestCase
2357 fixtures :developers # you can add more with comma separation
2360 assert_equal 3, @developers.size # the container for all the fixtures is automatically set
2361 assert_kind_of Developer, @david # works like @developers["david"].find
2362 assert_equal "David Heinemeier Hansson", @david.name
2366 * Added HasAndBelongsToManyAssociation#push_with_attributes(object, join_attributes) that can create associations in the join table with additional
2367 attributes. This is really useful when you have information that's only relevant to the join itself, such as a "added_on" column for an association
2368 between post and category. The added attributes will automatically be injected into objects retrieved through the association similar to the piggy-back
2371 post.categories.push_with_attributes(category, :added_on => Date.today)
2372 post.categories.first.added_on # => Date.today
2374 NOTE: The categories table doesn't have a added_on column, it's the categories_post join table that does!
2376 * Fixed that :exclusively_dependent and :dependent can't be activated at the same time on has_many associations [Jeremy Kemper]
2378 * Fixed that database passwords couldn't be all numeric [Jeremy Kemper]
2380 * Fixed that calling id would create the instance variable for new_records preventing them from being saved correctly [Jeremy Kemper]
2382 * Added sanitization feature to HasManyAssociation#find_all so it works just like Base.find_all [Sam Stephenson/bitsweat]
2384 * Added that you can pass overlapping ids to find without getting duplicated records back [Jeremy Kemper]
2386 * Added that Base.benchmark returns the result of the block [Jeremy Kemper]
2388 * Fixed problem with unit tests on Windows with SQLite [paterno]
2390 * Fixed that quotes would break regular non-yaml fixtures [Dmitry Sabanin/daft]
2392 * Fixed fixtures on windows with line endings cause problems under unix / mac [Tobias Luetke]
2394 * Added HasAndBelongsToManyAssociation#find(id) that'll search inside the collection and find the object or record with that id
2396 * Added :conditions option to has_and_belongs_to_many that works just like the one on all the other associations
2398 * Added AssociationCollection#clear to remove all associations from has_many and has_and_belongs_to_many associations without destroying the records [geech]
2400 * Added type-checking and remove in 1-instead-of-N sql statements to AssociationCollection#delete [geech]
2402 * Added a return of self to AssociationCollection#<< so appending can be chained, like project << Milestone.create << Milestone.create [geech]
2404 * Added Base#hash and Base#eql? which means that all of the equality using features of array and other containers now works:
2406 [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
2408 * Added :uniq as an option to has_and_belongs_to_many which will automatically ensure that AssociateCollection#uniq is called
2409 before pulling records out of the association. This is especially useful for three-way (and above) has_and_belongs_to_many associations.
2411 * Added AssociateCollection#uniq which is especially useful for has_and_belongs_to_many associations that can include duplicates,
2412 which is common on associations that also use metadata. Usage: post.categories.uniq
2414 * Fixed respond_to? to use a subclass specific hash instead of an Active Record-wide one
2416 * Fixed has_and_belongs_to_many to treat associations between classes in modules properly [Florian Weber]
2418 * Added a NoMethod exception to be raised when query and writer methods are called for attributes that doesn't exist [geech]
2420 * Added a more robust version of Fixtures that throws meaningful errors when on formatting issues [geech]
2422 * Added Base#transaction as a compliment to Base.transaction for prettier use in instance methods [geech]
2424 * Improved the speed of respond_to? by placing the dynamic methods lookup table in a hash [geech]
2426 * Added that any additional fields added to the join table in a has_and_belongs_to_many association
2427 will be placed as attributes when pulling records out through has_and_belongs_to_many associations.
2428 This is helpful when have information about the association itself that you want available on retrival.
2430 * Added better loading exception catching and RubyGems retries to the database adapters [alexeyv]
2432 * Fixed bug with per-model transactions [daniel]
2434 * Fixed Base#transaction so that it returns the result of the last expression in the transaction block [alexeyv]
2436 * Added Fixture#find to find the record corresponding to the fixture id. The record
2437 class name is guessed by using Inflector#classify (also new) on the fixture directory name.
2439 Before: Document.find(@documents["first"]["id"])
2440 After : @documents["first"].find
2442 * Fixed that the table name part of column names ("TABLE.COLUMN") wasn't removed properly [Andreas Schwarz]
2444 * Fixed a bug with Base#size when a finder_sql was used that didn't capitalize SELECT and FROM [geech]
2446 * Fixed quoting problems on SQLite by adding quote_string to the AbstractAdapter that can be overwritten by the concrete
2447 adapters for a call to the dbm. [Andreas Schwarz]
2449 * Removed RubyGems backup strategy for requiring SQLite-adapter -- if people want to use gems, they're already doing it with AR.
2454 * Added OO-style associations methods [Florian Weber]. Examples:
2456 Project#milestones_count => Project#milestones.size
2457 Project#build_to_milestones => Project#milestones.build
2458 Project#create_for_milestones => Project#milestones.create
2459 Project#find_in_milestones => Project#milestones.find
2460 Project#find_all_in_milestones => Project#milestones.find_all
2462 * Added serialize as a new class method to control when text attributes should be YAMLized or not. This means that automated
2463 serialization of hashes, arrays, and so on WILL NO LONGER HAPPEN (#10). You need to do something like this:
2465 class User < ActiveRecord::Base
2469 This will assume that settings is a text column and will now YAMLize any object put in that attribute. You can also specify
2470 an optional :class_name option that'll raise an exception if a serialized object is retrieved as a descendent of a class not in
2471 the hierarchy. Example:
2473 class User < ActiveRecord::Base
2474 serialize :settings, :class_name => "Hash"
2477 user = User.create("settings" => %w( one two three ))
2478 User.find(user.id).settings # => raises SerializationTypeMismatch
2480 * Added the option to connect to a different database for one model at a time. Just call establish_connection on the class
2481 you want to have connected to another database than Base. This will automatically also connect decendents of that class
2482 to the different database [Renald Buter].
2484 * Added transactional protection for Base#save. Validations can now check for values knowing that it happens in a transaction and callbacks
2485 can raise exceptions knowing that the save will be rolled back. [Suggested by Alexey Verkhovsky]
2487 * Added column name quoting so reserved words, such as "references", can be used as column names [Ryan Platte]
2489 * Added the possibility to chain the return of what happened inside a logged block [geech]:
2492 log { ... }.map { ... }
2496 log { result = ... }
2499 * Added "socket" option for the MySQL adapter, so you can change it to something else than "/tmp/mysql.sock" [Anna Lissa Cruz]
2501 * Added respond_to? answers for all the attribute methods. So if Person has a name attribute retrieved from the table schema,
2502 person.respond_to? "name" will return true.
2504 * Added Base.benchmark which can be used to aggregate logging and benchmark, so you can measure and represent multiple statements in a single block.
2505 Usage (hides all the SQL calls for the individual actions and calculates total runtime for them all):
2507 Project.benchmark("Creating project") do
2508 project = Project.create("name" => "stuff")
2509 project.create_manager("name" => "David")
2510 project.milestones << Milestone.find_all
2513 * Added logging of invalid SQL statements [Suggested by Daniel Von Fange]
2515 * Added alias Errors#[] for Errors#on, so you can now say person.errors["name"] to retrieve the errors for name [Andreas Schwarz]
2517 * Added RubyGems require attempt if sqlite-ruby is not available through regular methods.
2519 * Added compatibility with 2.x series of sqlite-ruby drivers. [Jamis Buck]
2521 * Added type safety for association assignments, so a ActiveRecord::AssociationTypeMismatch will be raised if you attempt to
2522 assign an object that's not of the associated class. This cures the problem with nil giving id = 4 and fixnums giving id = 1 on
2523 mistaken association assignments. [Reported by Andreas Schwarz]
2525 * Added the option to keep many fixtures in one single YAML document [what-a-day]
2527 * Added the class method "inheritance_column" that can be overwritten to return the name of an alternative column than "type" for storing
2528 the type for inheritance hierarchies. [Dave Steinberg]
2530 * Added [] and []= as an alternative way to access attributes when the regular methods have been overwritten [Dave Steinberg]
2532 * Added the option to observer more than one class at the time by specifying observed_class as an array
2534 * Added auto-id propagation support for tables with arbitrary primary keys that have autogenerated sequences associated with them
2535 on PostgreSQL. [Dave Steinberg]
2537 * Changed that integer and floats set to "" through attributes= remain as NULL. This was especially a problem for scaffolding and postgresql. (#49)
2539 * Changed the MySQL Adapter to rely on MySQL for its defaults for socket, host, and port [Andreas Schwarz]
2541 * Changed ActionControllerError to decent from StandardError instead of Exception. It can now be caught by a generic rescue.
2543 * Changed class inheritable attributes to not use eval [Caio Chassot]
2545 * Changed Errors#add to now use "invalid" as the default message instead of true, which means full_messages work with those [Marcel Molina Jr]
2547 * Fixed spelling on Base#add_on_boundry_breaking to Base#add_on_boundary_breaking (old naming still works) [Marcel Molina Jr.]
2549 * Fixed that entries in the has_and_belongs_to_many join table didn't get removed when an associated object was destroyed.
2551 * Fixed unnecessary calls to SET AUTOCOMMIT=0/1 for MySQL adapter [Andreas Schwarz]
2553 * Fixed PostgreSQL defaults are now handled gracefully [Dave Steinberg]
2555 * Fixed increment/decrement_counter are now atomic updates [Andreas Schwarz]
2557 * Fixed the problems the Inflector had turning Attachment into attuchments and Cases into Casis [radsaq/Florian Gross]
2559 * Fixed that cloned records would point attribute references on the parent object [Andreas Schwarz]
2561 * Fixed SQL for type call on inheritance hierarchies [Caio Chassot]
2563 * Fixed bug with typed inheritance [Florian Weber]
2565 * Fixed a bug where has_many collection_count wouldn't use the conditions specified for that association
2570 * Expanded the table_name guessing rules immensely [Florian Green]. Documentation:
2572 Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending
2573 directly from ActiveRecord. So if the hierarchy looks like: Reply < Message < ActiveRecord, then Message is used
2574 to guess the table name from even when called on Reply. The guessing rules are as follows:
2575 * Class name ends in "x", "ch" or "ss": "es" is appended, so a Search class becomes a searches table.
2576 * Class name ends in "y" preceded by a consonant or "qu": The "y" is replaced with "ies",
2577 so a Category class becomes a categories table.
2578 * Class name ends in "fe": The "fe" is replaced with "ves", so a Wife class becomes a wives table.
2579 * Class name ends in "lf" or "rf": The "f" is replaced with "ves", so a Half class becomes a halves table.
2580 * Class name ends in "person": The "person" is replaced with "people", so a Salesperson class becomes a salespeople table.
2581 * Class name ends in "man": The "man" is replaced with "men", so a Spokesman class becomes a spokesmen table.
2582 * Class name ends in "sis": The "i" is replaced with an "e", so a Basis class becomes a bases table.
2583 * Class name ends in "tum" or "ium": The "um" is replaced with an "a", so a Datum class becomes a data table.
2584 * Class name ends in "child": The "child" is replaced with "children", so a NodeChild class becomes a node_children table.
2585 * Class name ends in an "s": No additional characters are added or removed.
2586 * Class name doesn't end in "s": An "s" is appended, so a Comment class becomes a comments table.
2587 * Class name with word compositions: Compositions are underscored, so CreditCard class becomes a credit_cards table.
2588 Additionally, the class-level table_name_prefix is prepended to the table_name and the table_name_suffix is appended.
2589 So if you have "myapp_" as a prefix, the table name guess for an Account class becomes "myapp_accounts".
2591 You can also overwrite this class method to allow for unguessable links, such as a Mouse class with a link to a
2592 "mice" table. Example:
2594 class Mouse < ActiveRecord::Base
2595 def self.table_name() "mice" end
2598 This conversion is now done through an external class called Inflector residing in lib/active_record/support/inflector.rb.
2600 * Added find_all_in_collection to has_many defined collections. Works like this:
2602 class Firm < ActiveRecord::Base
2607 firm.find_all_in_clients "revenue > 1000" # SELECT * FROM clients WHERE firm_id = 1 AND revenue > 1000
2609 [Requested by Dave Thomas]
2611 * Fixed finders for inheritance hierarchies deeper than one level [Florian Weber]
2613 * Added add_on_boundry_breaking to errors to accompany add_on_empty as a default validation method. It's used like this:
2615 class Person < ActiveRecord::Base
2618 errors.add_on_boundry_breaking "password", 3..20
2622 This will add an error to the tune of "is too short (minimum is 3 characters)" or "is too long (minimum is 20 characters)" if
2623 the password is outside the boundry. The messages can be changed by passing a third and forth parameter as message strings.
2625 * Implemented a clone method that works properly with AR. It returns a clone of the record that
2626 hasn't been assigned an id yet and is treated as a new record.
2628 * Allow for domain sockets in PostgreSQL by not assuming localhost when no host is specified [Scott Barron]
2630 * Fixed that bignums are saved properly instead of attempted to be YAMLized [Andreas Schwartz]
2632 * Fixed a bug in the GEM where the rdoc options weren't being passed according to spec [Chad Fowler]
2634 * Fixed a bug with the exclusively_dependent option for has_many
2639 * Correctly guesses the primary key when the class is inside a module [Dave Steinberg].
2641 * Added [] and []= as alternatives to read_attribute and write_attribute [Dave Steinberg]
2643 * has_and_belongs_to_many now accepts an :order key to determine in which order the collection is returned [radsaq].
2645 * The ids passed to find and find_on_conditions are now automatically sanitized.
2647 * Added escaping of plings in YAML content.
2649 * Multi-parameter assigns where all the parameters are empty will now be set to nil instead of a new instance of their class.
2651 * Proper type within an inheritance hierarchy is now ensured already at object initialization (instead of first at create)
2656 * Fixed bug with using a different primary key name together with has_and_belongs_to_many [Investigation by Scott]
2658 * Added :exclusively_dependent option to the has_many association macro. The doc reads:
2660 If set to true all the associated object are deleted in one SQL statement without having their
2661 before_destroy callback run. This should only be used on associations that depend solely on
2662 this class and don't need to do any clean-up in before_destroy. The upside is that it's much
2663 faster, especially if there's a counter_cache involved.
2665 * Added :port key to connection options, so the PostgreSQL and MySQL adapters can connect to a database server
2666 running on another port than the default.
2668 * Converted the new natural singleton methods that prevented AR objects from being saved by PStore
2669 (and hence be placed in a Rails session) to a module. [Florian Weber]
2671 * Fixed the use of floats (was broken since 0.9.0+)
2673 * Fixed PostgreSQL adapter so default values are displayed properly when used in conjunction with
2674 Action Pack scaffolding.
2676 * Fixed booleans support for PostgreSQL (use real true/false on boolean fields instead of 0/1 on tinyints) [radsaq]
2681 * Added static method for instantly updating a record
2683 * Treat decimal and numeric as Ruby floats [Andreas Schwartz]
2685 * Treat chars as Ruby strings (fixes problem for Action Pack form helpers too)
2687 * Removed debugging output accidently left in (which would screw web applications)
2694 * Added natural object-style assignment for has_and_belongs_to_many associations. Consider the following model:
2696 class Event < ActiveRecord::Base
2697 has_one_and_belongs_to_many :sponsors
2700 class Sponsor < ActiveRecord::Base
2701 has_one_and_belongs_to_many :sponsors
2704 Earlier, you'd have to use synthetic methods for creating associations between two objects of the above class:
2706 roskilde_festival.add_to_sponsors(carlsberg)
2707 roskilde_festival.remove_from_sponsors(carlsberg)
2709 nike.add_to_events(world_cup)
2710 nike.remove_from_events(world_cup)
2712 Now you can use regular array-styled methods:
2714 roskilde_festival.sponsors << carlsberg
2715 roskilde_festival.sponsors.delete(carlsberg)
2717 nike.events << world_cup
2718 nike.events.delete(world_cup)
2720 * Added delete method for has_many associations. Using this will nullify an association between the has_many and the belonging
2721 object by setting the foreign key to null. Consider this model:
2723 class Post < ActiveRecord::Base
2727 class Comment < ActiveRecord::Base
2731 You could do something like:
2733 funny_comment.has_post? # => true
2734 announcement.comments.delete(funny_comment)
2735 funny_comment.has_post? # => false
2740 * Active Record is now thread safe! (So you can use it with Cerise and WEBrick applications)
2741 [Implementation idea by Michael Neumann, debugging assistance by Jamis Buck]
2743 * Improved performance by roughly 400% on a basic test case of pulling 100 records and querying one attribute.
2744 This brings the tax for using Active Record instead of "riding on the metal" (using MySQL-ruby C-driver directly) down to ~50%.
2745 Done by doing lazy type conversions and caching column information on the class-level.
2747 * Added callback objects and procs as options for implementing the target for callback macros.
2749 * Added "counter_cache" option to belongs_to that automates the usage of increment_counter and decrement_counter. Consider:
2751 class Post < ActiveRecord::Base
2755 class Comment < ActiveRecord::Base
2759 Iterating over 100 posts like this:
2761 <% for post in @posts %>
2762 <%= post.title %> has <%= post.comments_count %> comments
2765 Will generate 100 SQL count queries -- one for each call to post.comments_count. If you instead add a "comments_count" int column
2766 to the posts table and rewrite the comments association macro with:
2768 class Comment < ActiveRecord::Base
2769 belongs_to :post, :counter_cache => true
2772 Those 100 SQL count queries will be reduced to zero. Beware that counter caching is only appropriate for objects that begin life
2773 with the object it's specified to belong with and is destroyed like that as well. Typically objects where you would also specify
2774 :dependent => true. If your objects switch from one belonging to another (like a post that can be move from one category to another),
2775 you'll have to manage the counter yourself.
2777 * Added natural object-style assignment for has_one and belongs_to associations. Consider the following model:
2779 class Project < ActiveRecord::Base
2783 class Manager < ActiveRecord::Base
2787 Earlier, assignments would work like following regardless of which way the assignment told the best story:
2789 active_record.manager_id = david.id
2791 Now you can do it either from the belonging side:
2793 david.project = active_record
2795 ...or from the having side:
2797 active_record.manager = david
2799 If the assignment happens from the having side, the assigned object is automatically saved. So in the example above, the
2800 project_id attribute on david would be set to the id of active_record, then david would be saved.
2802 * Added natural object-style assignment for has_many associations [Florian Weber]. Consider the following model:
2804 class Project < ActiveRecord::Base
2805 has_many :milestones
2808 class Milestone < ActiveRecord::Base
2812 Earlier, assignments would work like following regardless of which way the assignment told the best story:
2814 deadline.project_id = active_record.id
2816 Now you can do it either from the belonging side:
2818 deadline.project = active_record
2820 ...or from the having side:
2822 active_record.milestones << deadline
2824 The milestone is automatically saved with the new foreign key.
2826 * API CHANGE: Attributes for text (or blob or similar) columns will now have unknown classes stored using YAML instead of using
2827 to_s. (Known classes that won't be yamelized are: String, NilClass, TrueClass, FalseClass, Fixnum, Date, and Time).
2828 Likewise, data pulled out of text-based attributes will be attempted converged using Yaml if they have the "--- " header.
2829 This was primarily done to be enable the storage of hashes and arrays without wrapping them in aggregations, so now you can do:
2832 user.preferences = { "background" => "black", "display" => large }
2835 User.find(1).preferences # => { "background" => "black", "display" => large }
2837 Please note that this method should only be used when you don't care about representing the object in proper columns in
2838 the database. A money object consisting of an amount and a currency is still a much better fit for a value object done through
2839 aggregations than this new option.
2841 * POSSIBLE CODE BREAKAGE: As a consequence of the lazy type conversions, it's a bad idea to reference the @attributes hash
2842 directly (it always was, but now it's paramount that you don't). If you do, you won't get the type conversion. So to implement
2843 new accessors for existing attributes, use read_attribute(attr_name) and write_attribute(attr_name, value) instead. Like this:
2845 class Song < ActiveRecord::Base
2846 # Uses an integer of seconds to hold the length of the song
2848 def length=(minutes)
2849 write_attribute("length", minutes * 60)
2853 read_attribute("length") / 60
2857 The clever kid will notice that this opens a door to sidestep the automated type conversion by using @attributes directly.
2858 This is not recommended as read/write_attribute may be granted additional responsibilities in the future, but if you think
2859 you know what you're doing and aren't afraid of future consequences, this is an option.
2861 * Applied a few minor bug fixes reported by Daniel Von Fange.
2868 * Added ActiveRecord::Reflection with a bunch of methods and classes for reflecting in aggregations and associations.
2870 * Added Base.columns and Base.content_columns which returns arrays of column description (type, default, etc) objects.
2872 * Added Base#attribute_names which returns an array of names for the attributes available on the object.
2874 * Added Base#column_for_attribute(name) which returns the column description object for the named attribute.
2879 * Added multi-parameter assignment:
2881 # Instantiate objects for all attribute classes that needs more than one constructor parameter. This is done
2882 # by calling new on the column type or aggregation type (through composed_of) object with these parameters.
2883 # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
2884 # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
2885 # parenteses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float,
2886 # s for String, and a for Array.
2888 This is incredibly useful for assigning dates from HTML drop-downs of month, year, and day.
2890 * Fixed bug with custom primary key column name and Base.find on multiple parameters.
2892 * Fixed bug with dependent option on has_one associations if there was no associated object.
2899 * Added transactional protection for destroy (important for the new :dependent option) [Suggested by Carl Youngblood]
2901 * Fixed so transactions are ignored on MyISAM tables for MySQL (use InnoDB to get transactions)
2903 * Changed transactions so only exceptions will cause a rollback, not returned false.
2908 * Added support for non-integer primary keys [Aredridel/earlier work by Michael Neumann]
2911 Product.find "PDKEY-INT-12"
2913 * Added option to specify naming method for primary key column. ActiveRecord::Base.primary_key_prefix_type can either
2914 be set to nil, :table_name, or :table_name_with_underscore. :table_name will assume that Product class has a primary key
2915 of "productid" and :table_name_with_underscore will assume "product_id". The default nil will just give "id".
2917 * Added an overwriteable primary_key method that'll instruct AR to the name of the
2918 id column [Aredridele/earlier work by Guan Yang]
2920 class Project < ActiveRecord::Base
2921 def self.primary_key() "project_id" end
2924 * Fixed that Active Records can safely associate inside and out of modules.
2926 class MyApplication::Account < ActiveRecord::Base
2927 has_many :clients # will look for MyApplication::Client
2928 has_many :interests, :class_name => "Business::Interest" # will look for Business::Interest
2931 * Fixed that Active Records can safely live inside modules [Aredridel]
2933 class MyApplication::Account < ActiveRecord::Base
2939 * Added freeze call to value object assignments to ensure they remain immutable [Spotted by Gavin Sinclair]
2941 * Changed interface for specifying observed class in observers. Was OBSERVED_CLASS constant, now is
2942 observed_class() class method. This is more consistant with things like self.table_name(). Works like this:
2944 class AuditObserver < ActiveRecord::Observer
2945 def self.observed_class() Account end
2946 def after_update(account)
2947 AuditTrail.new(account, "UPDATED")
2951 [Suggested by Gavin Sinclair]
2953 * Create new Active Record objects by setting the attributes through a block. Like this:
2955 person = Person.new do |p|
2960 [Suggested by Gavin Sinclair]
2965 * Added inheritable callback queues that can ensure that certain callback methods or inline fragments are
2966 run throughout the entire inheritance hierarchy. Regardless of whether a descendent overwrites the callback
2969 class Topic < ActiveRecord::Base
2970 before_destroy :destroy_author, 'puts "I'm an inline fragment"'
2973 Learn more in link:classes/ActiveRecord/Callbacks.html
2975 * Added :dependent option to has_many and has_one, which will automatically destroy associated objects when
2976 the holder is destroyed:
2978 class Album < ActiveRecord::Base
2979 has_many :tracks, :dependent => true
2982 All the associated tracks are destroyed when the album is.
2984 * Added Base.create as a factory that'll create, save, and return a new object in one step.
2986 * Automatically convert strings in config hashes to symbols for the _connection methods. This allows you
2987 to pass the argument hashes directly from yaml. (Luke)
2989 * Fixed the install.rb to include simple.rb [Spotted by Kevin Bullock]
2991 * Modified block syntax to better follow our code standards outlined in
2992 http://www.rubyonrails.org/CodingStandards
2997 * Added object-level transactions [Thanks to Austin Ziegler for Transaction::Simple]
2999 * Changed adapter-specific connection methods to use centralized ActiveRecord::Base.establish_connection,
3000 which is parametized through a config hash with symbol keys instead of a regular parameter list.
3001 This will allow for database connections to be opened in a more generic fashion. (Luke)
3003 NOTE: This requires all *_connections to be updated! Read more in:
3004 http://ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000081
3006 * Fixed SQLite adapter so objects fetched from has_and_belongs_to_many have proper attributes
3007 (t.name is now name). [Spotted by Garrett Rooney]
3009 * Fixed SQLite adapter so dates are returned as Date objects, not Time objects [Spotted by Gavin Sinclair]
3011 * Fixed requirement of date class, so date conversions are succesful regardless of whether you
3012 manually require date or not.
3017 * Added transactions
3019 * Changed Base.find to also accept either a list (1, 5, 6) or an array of ids ([5, 7])
3020 as parameter and then return an array of objects instead of just an object
3022 * Fixed method has_collection? for has_and_belongs_to_many macro to behave as a
3023 collection, not an association
3025 * Fixed SQLite adapter so empty or nil values in columns of datetime, date, or time type
3026 aren't treated as current time [Spotted by Gavin Sinclair]
3031 * Fixed the install.rb to create the lib/active_record/support directory [Spotted by Gavin Sinclair]
3032 * Fixed that has_association? would always return true [Spotted by Daniel Von Fange]