2005-07-14 03:18:26 -04:00
*SVN*
2005-09-25 11:49:35 -04:00
* Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior)
2005-09-25 04:48:30 -04:00
* Added new symbol-driven approach to activating observers with Base#observers= [DHH]. Example:
2005-09-24 19:58:13 -04:00
2005-09-25 04:48:30 -04:00
ActiveRecord::Base.observers = :cacher, :garbage_collector
2005-09-23 13:27:59 -04:00
2005-09-25 04:26:29 -04:00
* 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]
* Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck]
* Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck]
* 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]
2005-09-23 09:29:33 -04:00
2005-09-21 09:27:45 -04:00
* Fixed migrations for Windows when using more than 10 [David Naseby]
2005-09-20 14:36:14 -04:00
* Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber]
2005-09-20 12:12:13 -04:00
* Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Luetke]
2005-09-19 21:33:43 -04:00
* Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar]
2005-09-19 12:34:34 -04:00
* Fixed that Observers didn't observe sub-classes #627 [Florian Weber]
2005-09-18 16:41:44 -04:00
* Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina]
2005-09-15 02:42:07 -04:00
* 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]
2005-09-15 02:40:39 -04:00
2005-09-13 06:15:54 -04:00
* Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber]
2005-09-11 05:41:24 -04:00
* Added better exception error when unknown column types are used with migrations #1814 [fbeausoleil@ftml.net]
2005-09-11 01:43:46 -04:00
* Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com]
2005-09-09 04:54:02 -04:00
* Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg]
2005-09-09 04:37:05 -04:00
* Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward]
2005-09-09 04:01:44 -04:00
* Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code]
2005-09-08 08:21:36 -04:00
* 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]
* 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/
2005-09-06 12:48:18 -04:00
2005-09-02 10:20:20 -04:00
* Make sure the schema_info table is created before querying the current version #1903
2005-09-02 06:51:23 -04:00
* Fixtures ignore table name prefix and suffix #1987 [Jakob S]
2005-09-02 06:07:14 -04:00
* Add documentation for index_type argument to add_index method for migrations #2005 [blaine@odeo.com]
2005-09-02 04:31:11 -04:00
* Modify read_attribute to allow a symbol argument #2024 [Ken Kunz]
2005-08-14 04:59:18 -04:00
* Make destroy return self #1913 [sebastian.kanthak@muehlheim.de]
2005-08-14 04:50:51 -04:00
* Fix typo in validations documentation #1938 [court3nay]
2005-08-14 04:35:08 -04:00
* Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org]
2005-08-14 04:20:51 -04:00
* Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky]
2005-07-30 06:16:21 -04:00
* Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com]
2005-07-27 13:06:22 -04:00
* Fix create_table so that id column is implicitly added [Rick Olson]
2005-07-24 10:01:35 -04:00
* 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
* OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798
* Fixed the handling of camelCase columns names in Oracle #1798
* 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
* Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798
2005-07-22 16:05:42 -04:00
* Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Luetke]
class Comment < AR:B
def self.search(q)
find(:all, :conditions => ["body = ?", q])
end
end
class Post < AR:B
has_many :comments
end
Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi'
2005-07-22 16:40:27 -04:00
NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as
by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on
details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself
noticed :)
2005-07-22 16:05:42 -04:00
2005-07-22 15:58:03 -04:00
* Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson]
2005-07-22 12:52:59 -04:00
* Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar]
2005-07-20 08:47:55 -04:00
* Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions
2005-07-17 05:52:00 -04:00
* Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt]
2005-07-14 03:18:26 -04:00
* 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]
2005-07-11 03:36:18 -04:00
*1.11.1* (11 July, 2005)
2005-07-07 04:48:59 -04:00
2005-07-11 02:09:08 -04:00
* 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]
2005-07-10 01:31:29 -04:00
* 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]
2005-07-10 00:54:34 -04:00
* 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]
2005-07-10 00:25:39 -04:00
* Correct reflected table name for singular associations. #1688 [court3nay@gmail.com]
2005-07-09 13:02:32 -04:00
* Fixed optimistic locking with SQL Server #1660 [tom@popdog.net]
2005-07-09 11:46:29 -04:00
* Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current
2005-07-08 15:22:37 -04:00
* Added better error message for "packets out of order" #1630 [courtenay]
2005-07-07 04:48:59 -04:00
* Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640
2005-07-11 03:36:18 -04:00
*1.11.0* (6 July, 2005)
2005-04-24 12:25:57 -04:00
2005-07-06 06:16:38 -04:00
* Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar]
2005-07-05 13:23:41 -04:00
* Changed logging of SQL statements to use the DEBUG level instead of INFO
2005-07-04 14:51:02 -04:00
* 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.
2005-07-04 04:43:57 -04:00
* Added callback hooks to association collections #1549 [Florian Weber]. Example:
class Project
has_and_belongs_to_many :developers, :before_add => :evaluate_velocity
def evaluate_velocity(developer)
...
end
end
..raising an exception will cause the object not to be added (or removed, with before_remove).
2005-07-03 08:34:22 -04:00
* Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry]
2005-07-03 05:51:24 -04:00
* Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato]
2005-07-03 04:52:59 -04:00
* Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber]
2005-07-03 04:27:18 -04:00
* Speed up ActiveRecord#method_missing for the common case (read_attribute).
2005-07-03 05:04:52 -04:00
* Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [skaes@web.de]
2005-07-03 04:27:18 -04:00
2005-07-03 04:21:22 -04:00
* Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath]
2005-07-02 03:52:29 -04:00
* Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at]
2005-07-01 14:33:38 -04:00
* Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [michael@schuerig.de]
2005-07-01 13:20:04 -04:00
* Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry]
* Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry]
2005-06-28 13:15:01 -04:00
* Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net]
2005-06-26 00:49:52 -04:00
* Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl]
2005-06-25 07:47:37 -04:00
* 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:
Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
...should instead be:
Developer.find(
:all,
:joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
:conditions => 'project_id=1'
)
2005-06-25 07:24:43 -04:00
* Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina]
2005-06-25 06:56:20 -04:00
* 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]
2005-06-21 12:36:18 -04:00
* Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379
2005-06-18 01:28:59 -04:00
* 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]
2005-06-17 06:08:41 -04:00
* 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
2005-06-16 02:46:22 -04:00
* Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper]
2005-06-16 02:44:48 -04:00
2005-06-16 01:35:10 -04:00
* Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak].
Example:
david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")]
david.save
If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new
project is saved when david.save is called.
Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do:
david.project_ids = [1, 5, 7]
2005-06-13 17:51:43 -04:00
* Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com]
2005-06-13 00:42:36 -04:00
* Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Luetke]
2005-06-12 18:05:30 -04:00
* 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]
2005-06-12 09:32:06 -04:00
* Corrected @@configurations typo #1410 [david@ruppconsulting.com]
2005-06-12 02:56:51 -04:00
* Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com]
2005-06-11 06:06:47 -04:00
* Allow before/after update hooks to work on models using optimistic locking
2005-06-10 09:54:58 -04:00
* Eager loading of dependent has_one associations won't delete the association #1212
2005-06-06 17:10:59 -04:00
* 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.
2005-06-03 12:06:38 -04:00
* Using transactional fixtures now causes the data to be loaded only once.
2005-06-03 07:49:34 -04:00
* Added fixture accessor methods that can be used when instantiated fixtures are disabled.
fixtures :web_sites
def test_something
assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
end
2005-05-21 14:51:08 -04:00
* Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar]
* Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar]
2005-05-21 14:12:36 -04:00
* CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309
* Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead
2005-05-21 06:57:18 -04:00
* 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:
Conditional validations such as the following are made possible:
validates_numericality_of :income, :if => :employed?
Conditional validations can also solve the salted login generator problem:
validates_confirmation_of :password, :if => :new_password?
Using blocks:
validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 }
2005-05-19 13:23:28 -04:00
* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
2005-05-19 13:07:56 -04:00
* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
2005-06-16 02:46:22 -04:00
* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper]
2005-05-19 12:42:47 -04:00
2005-05-02 12:48:07 -04:00
* 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.
2005-05-02 12:46:30 -04:00
* 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.
2005-05-02 01:34:27 -04:00
* Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example:
# SELECT * FROM topics WHERE title IN ('First', 'Second')
Topic.find_all_by_title(["First", "Second"])
2005-04-30 11:49:28 -04:00
* Added compatibility with camelCase column names for dynamic finders #533 [Dee.Zsombor]
2005-04-30 11:45:15 -04:00
* Fixed extraneous comma in count() function that made it not work with joins #1156 [jarkko/Dee.Zsombor]
2005-04-30 10:04:01 -04:00
* Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid]
2005-04-30 10:02:03 -04:00
* Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com]
2005-04-30 09:21:47 -04:00
* Added encoding and min_messages options for PostgreSQL #1205 [shugo]. Configuration example:
development:
adapter: postgresql
database: rails_development
host: localhost
username: postgres
password:
encoding: UTF8
min_messages: ERROR
2005-04-25 12:11:31 -04:00
* 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]
2005-04-24 12:25:57 -04:00
* Added validates_exclusion_of as a negative of validates_inclusion_of
* 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
2005-04-19 12:32:57 -04:00
*1.10.1* (20th April, 2005)
2005-04-19 13:05:54 -04:00
* Fixed frivilous database queries being triggered with eager loading on empty associations and other things
2005-04-19 12:32:57 -04:00
* Fixed order of loading in eager associations
2005-04-19 01:24:50 -04:00
* Fixed stray comma when using eager loading and ordering together from has_many associations #1143
2005-04-18 16:10:11 -04:00
*1.10.0* (19th April, 2005)
2005-04-18 15:19:23 -04:00
2005-04-18 10:39:36 -04:00
* Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example:
for post in Post.find(:all, :limit => 100)
puts "Post: " + post.title
puts "Written by: " + post.author.name
puts "Last comment on: " + post.comments.first.created_on
end
This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as:
for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ])
...and the number of database queries needed is now 1.
* Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples:
Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC")
Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC")
Person.find(:first, :order => "created_on DESC", :offset => 5)
Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
Person.find(:all, :offset => 10, :limit => 10)
2005-04-18 16:10:11 -04:00
* Added acts_as_nested_set #1000 [wschenk]. Introduction:
This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with
the added feature that you can select the children and all of it's descendants with
a single query. A good use case for this is a threaded post system, where you want
to display every reply to a comment without multiple selects.
* 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]
2005-04-18 04:11:15 -04:00
* Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com]
2005-04-18 03:52:58 -04:00
* Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com]
2005-04-18 01:55:20 -04:00
* Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com]
2005-04-17 13:16:24 -04:00
* Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher]
2005-04-17 09:59:02 -04:00
* Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle]
2005-04-17 06:04:07 -04:00
* Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com]
2005-04-17 02:50:17 -04:00
* Added insert_at(position) to acts_as_list #1083 [DeLynnB]
2005-04-13 13:51:43 -04:00
* 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)
2005-04-13 01:16:52 -04:00
* Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com]
2005-04-13 00:46:59 -04:00
* Fixed boolean saving on Oracle #1093 [mparrish@pearware.org]
2005-04-12 01:34:10 -04:00
* 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
2005-04-10 13:34:29 -04:00
* Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt]
2005-04-07 02:54:25 -04:00
* Added quoting of column names for fixtures #997 [jcfischer@gmail.com]
2005-04-07 02:29:31 -04:00
* Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis]
2005-04-02 04:31:58 -05:00
* Fixed that benchmarking times for rendering included db runtimes #987 [skaes@web.de]
2005-04-02 03:58:43 -05:00
* Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org]
2005-06-16 02:46:22 -04:00
* 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]
2005-04-02 03:52:51 -05:00
2005-04-02 03:42:21 -05:00
* Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org]
2005-04-02 03:31:26 -05:00
* Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de]
2005-04-02 03:29:54 -05:00
* Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de]
2005-03-31 09:35:14 -05:00
2005-03-30 09:25:29 -05:00
* Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas]
2005-03-30 08:06:19 -05:00
* 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)
2005-03-27 09:10:42 -05:00
*1.9.1* (27th March, 2005)
* Fixed that Active Record objects with float attribute could not be cloned #808
2005-03-22 19:56:13 -05:00
2005-03-25 04:07:01 -05:00
* Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar]
2005-03-23 18:39:18 -05:00
* Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count
2005-03-22 19:57:38 -05:00
* Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron]
2005-03-22 19:56:13 -05:00
* 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]
2005-03-22 07:41:34 -05:00
*1.9.0* (22th March, 2005)
2005-03-10 09:44:01 -05:00
2005-03-20 16:56:50 -05:00
* 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:
Developer.find_all nil, 'id ASC', 5 # return the first five developers
Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward
This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged.
2005-03-20 10:45:36 -05:00
* 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]
2005-03-20 09:33:45 -05:00
* Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins]
2005-03-20 09:25:26 -05:00
* 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]
2005-03-20 08:42:35 -05:00
* Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel]
2005-03-20 08:39:15 -05:00
* 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]
2005-03-17 14:36:44 -05:00
* Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com]
2005-03-17 09:12:25 -05:00
* Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net]
2005-03-14 18:56:47 -05:00
* Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak]
* Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak]
2005-03-14 18:48:39 -05:00
* Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm]
2005-03-13 19:04:14 -05:00
* Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself
2005-03-10 09:44:01 -05:00
* Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body)
2005-03-06 20:50:58 -05:00
*1.8.0* (7th March, 2005)
2005-02-27 12:18:35 -05:00
2005-03-06 12:18:34 -05:00
* Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default)
2005-03-06 09:31:38 -05:00
* Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron]
2005-03-06 09:11:26 -05:00
* Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation:
* +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the
+attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+
objects that should be inspected to determine which attributes triggered the errors.
* +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method.
You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error.
* Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k]
2005-06-16 02:46:22 -04:00
* 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]
2005-03-06 08:51:55 -05:00
2005-03-06 08:40:21 -05:00
* Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example:
class Account < ActiveRecord::Base
has_one :credit_card, :dependent => true
end
class CreditCard < ActiveRecord::Base
belongs_to :account
end
account.credit_card # => returns existing credit card, lets say id = 12
account.credit_card = CreditCard.create("number" => "123")
account.save # => CC with id = 12 is destroyed
2005-03-06 07:43:23 -05:00
* Added validates_numericality_of #716 [skanthak/c.r.mcgrath]. Docuemntation:
Validates whether the value of the specified attribute is numeric by trying to convert it to
a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression
<tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true).
class Person < ActiveRecord::Base
validates_numericality_of :value, :on => :create
end
Configuration options:
* <tt>message</tt> - A custom error message (default is: "is not a number")
* <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update)
* <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false)
2005-03-06 06:53:49 -05:00
* Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron]
2005-03-01 18:52:36 -05:00
* 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)
2005-02-27 12:18:35 -05:00
* Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com]
2005-02-24 08:16:41 -05:00
*1.7.0* (24th February, 2005)
2005-02-07 08:43:44 -05:00
2005-02-24 07:00:42 -05:00
* 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]
2005-02-23 08:34:57 -05:00
* Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes:
1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple
and safe way of passing table-specific sequence information to the adapter.)
2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to
resort to some hacks to get data converted to Date or Time in Ruby.
If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the
hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time.
This is nasty - but if you use Duck Typing you'll probably not care very much.
In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is
valid - too many databases use DATE for both.
Timezones and sub-second precision on timestamps are not supported.
3. Default values that are functions (such as "SYSDATE") are not supported. This is a
restriction of the way active record supports default values.
4. Referential integrity constraints are not fully supported. Under at least
some circumstances, active record appears to delete parent and child records out of
sequence and out of transaction scope. (Or this may just be a problem of test setup.)
2005-02-23 08:39:32 -05:00
The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/
2005-02-23 07:31:05 -05:00
* Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke]
2005-02-22 08:58:22 -05:00
* Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm]
2005-02-22 08:54:26 -05:00
* 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]
2005-02-20 20:44:15 -05:00
* Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar]
2005-02-20 16:47:09 -05:00
* 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]
2005-02-20 16:21:41 -05:00
* Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au]
2005-02-19 06:30:38 -05:00
* Fixed that find_by_* would fail when column names had numbers #670 [demetrius]
2005-02-18 19:05:40 -05:00
* Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn]
1. Created a new columns method that is much cleaner.
2. Corrected a problem with the select and select_all methods
that didn't account for the LIMIT clause being passed into raw SQL statements.
3. Implemented the string_to_time method in order to create proper instances of the time class.
4. Added logic to the simplified_type method that allows the database to specify the scale of float data.
5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string.
2005-02-18 12:16:04 -05:00
* Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow@yahoo.com]
2005-06-16 02:46:22 -04:00
* Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example:
2005-02-17 18:03:48 -05:00
class Person < ActiveRecord::Base
validates_each :first_name, :last_name do |record, attr|
record.errors.add attr, 'starts with z.' if attr[0] == ?z
end
end
2005-06-16 02:46:22 -04:00
* 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]
2005-02-17 18:03:48 -05:00
2005-02-17 14:14:15 -05:00
* Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example:
class Person < ActiveRecord::Base
validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID }
end
* Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates]
2005-02-07 09:26:57 -05:00
* Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example:
class Project < ActiveRecord::Base
primary_key "sysid"
table_name "XYZ_PROJECT"
inheritance_column { original_inheritance_column + "_id" }
end
2005-02-07 08:43:44 -05:00
* Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu]
2005-01-25 15:10:24 -05:00
*1.6.0* (January 25th, 2005)
2005-01-20 09:35:00 -05:00
2005-01-25 07:45:01 -05:00
* 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.
* Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336
* Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once.
* 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
people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
Person.update(people.keys, people.values)
2005-01-24 09:15:18 -05:00
2005-01-24 08:18:29 -05:00
* 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]
2005-01-24 08:06:12 -05:00
* Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat]
2005-01-24 08:02:50 -05:00
* Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius]
2005-06-16 02:46:22 -04:00
* Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper]
2005-01-24 06:57:22 -05:00
2005-01-24 06:39:23 -05:00
* 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]
2005-01-24 06:20:47 -05:00
* 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]
2005-01-23 12:24:54 -05:00
* Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not
2005-01-23 10:19:33 -05:00
* Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription
2005-01-20 09:36:39 -05:00
* Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius]
2005-01-20 09:35:00 -05:00
* Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron]
2005-01-18 09:13:12 -05:00
*1.5.1* (January 18th, 2005)
2005-01-18 04:54:12 -05:00
2005-01-18 06:07:03 -05:00
* 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]
2005-01-18 04:54:12 -05:00
* Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle]
2005-01-16 20:13:15 -05:00
*1.5.0* (January 17th, 2005)
2005-01-05 21:31:35 -05:00
2005-01-15 12:54:45 -05:00
* Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel]
2005-01-15 12:52:08 -05:00
* Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example:
class Book < ActiveRecord::Base
has_many :pages
belongs_to :library
validates_associated :pages, :library
end
2005-01-15 12:45:16 -05:00
* Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition:
== Unsaved objects and associations
You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be
aware of, mostly involving the saving of associated objects.
=== One-to-one associations
* Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in
order to update their primary keys - except if the parent object is unsaved (new_record? == true).
* If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment
is cancelled.
* If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below).
* Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does
not save the parent either.
=== Collections
* Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object
(the owner of the collection) is not yet stored in the database.
* If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false.
* You can add an object to a collection without automatically saving it by using the #collection.build method (documented below).
* All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved.
* Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates]
* Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates]
* 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]
* Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates]
2005-01-15 08:48:39 -05:00
* Fixed binary support for PostgreSQL #444 [alex@byzantine.no]
2005-01-11 08:21:17 -05:00
* Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the
collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If
it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards,
it'll take one less SELECT query if you use length.
2005-01-10 19:45:26 -05:00
* 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]
2005-01-10 19:24:19 -05:00
* Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson]
2005-01-10 19:13:42 -05:00
* Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey]
2005-01-10 18:49:57 -05:00
* Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz]
2005-06-16 02:46:22 -04:00
* Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper]
2005-01-10 18:09:51 -05:00
2005-01-10 17:52:14 -05:00
* 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]
2005-01-10 14:18:37 -05:00
* Added that Observers can use the observes class method instead of overwriting self.observed_class().
Before:
class ListSweeper < ActiveRecord::Base
def self.observed_class() [ List, Item ]
end
After:
class ListSweeper < ActiveRecord::Base
observes List, Item
end
2005-01-06 22:55:24 -05:00
* Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is
2005-01-05 21:36:33 -05:00
* Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name
2005-01-05 21:31:35 -05:00
* Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag.
Before: topic.update_attribute(:approved, !approved?)
After : topic.toggle!(:approved)
* Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example:
page.views # => 1
page.increment!(:views) # executes an UPDATE statement
page.views # => 2
page.increment(:views).increment!(:views)
page.views # => 4
* Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns.
2005-01-04 07:35:10 -05:00
*1.4.0* (January 4th, 2005)
2004-12-28 11:27:08 -05:00
2005-01-04 07:35:10 -05:00
* Added automated optimistic locking if the field <tt>lock_version</tt> is present. Each update to the
record increments the lock_version column and the locking facilities ensure that records instantiated twice
will let the last one saved raise a StaleObjectError if the first was also updated. Example:
p1 = Person.find(1)
p2 = Person.find(1)
p1.first_name = "Michael"
p1.save
p2.first_name = "should fail"
p2.save # Raises a ActiveRecord::StaleObjectError
You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging,
or otherwise apply the business logic needed to resolve the conflict.
2005-01-02 13:44:55 -05:00
2005-01-04 07:35:10 -05:00
#384 [Michael Koziarski]
2005-01-02 10:09:03 -05:00
2005-01-02 08:31:00 -05:00
* Added dynamic attribute-based finders as a cleaner way of getting objects by simple queries without turning to SQL.
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,
Payment.find_by_transaction_id</tt>. So instead of writing <tt>Person.find_first(["user_name = ?", user_name])</tt>, you just do
<tt>Person.find_by_user_name(user_name)</tt>.
It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like
<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
<tt>Person.find_first(["user_name = ? AND password = ?", user_name, password])</tt>, you just do
<tt>Person.find_by_user_name_and_password(user_name, password)</tt>.
2005-01-02 08:51:00 -05:00
While primarily a construct for easier find_firsts, it can also be used as a construct for find_all by using calls like
<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,
though, as it's not possible to specify the order in which the objects are returned.
2005-06-16 02:46:22 -04:00
* Added block-style for callbacks #332 [Jeremy Kemper].
2005-01-01 11:14:15 -05:00
Before:
before_destroy(Proc.new{ |record| Person.destroy_all "firm_id = #{record.id}" })
After:
before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" }
2004-12-31 11:53:41 -05:00
* Added :counter_cache option to acts_as_tree that works just like the one you can define on belongs_to #371 [Josh]
2004-12-28 12:30:17 -05:00
* Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates
and times from the database. This is set to :local by default.
2004-12-28 11:27:08 -05:00
* Added the possibility for adapters to overwrite add_limit! to implement a different limiting scheme than "LIMIT X" used by MySQL, PostgreSQL, and SQLite.
2005-01-04 07:35:10 -05:00
* Added the possibility of having objects with acts_as_list created before their scope is available or...
* Added a db2 adapter that only depends on the Ruby/DB2 bindings (http://raa.ruby-lang.org/project/ruby-db2/) #386 [Maik Schmidt]
* Added the final touches to the Microsoft SQL Server adapter by Joey Gibson that makes it suitable for actual use #394 [DeLynn Barry]
2005-06-16 02:46:22 -04:00
* 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]
2005-01-04 07:35:10 -05:00
* Added HasManyAssociation#count that works like Base#count #413 [intinig]
* Fixed handling of binary content in blobs and similar fields for Ruby/MySQL and SQLite #409 [xal]
* Fixed a bug in the Ruby/MySQL that caused binary content to be escaped badly and come back mangled #405 [Tobias Luetke]
2004-12-28 11:27:08 -05:00
* Fixed that the const_missing autoload assumes the requested constant is set by require_association and calls const_get to retrieve it.
2005-06-16 02:46:22 -04:00
If require_association did not set the constant then const_get will call const_missing, resulting in an infinite loop #380 [Jeremy Kemper]
2004-12-28 11:27:08 -05:00
2005-01-04 07:35:10 -05:00
* Fixed broken transactions that were actually only running object-level and not db level transactions [andreas]
* Fixed that validates_uniqueness_of used 'id' instead of defined primary key #406
* Fixed that the overwritten respond_to? method didn't take two parameters like the original #391
* Fixed quoting in validates_format_of that would allow some rules to pass regardless of input #390 [Dmitry V. Sabanin]
2004-12-28 11:27:08 -05:00
*1.3.0* (December 23, 2004)
2004-12-21 18:41:07 -05:00
2004-12-20 08:21:01 -05:00
* 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:
before:
require_association 'person'
class Employee < Person
end
after:
class Employee < Person
end
This also reduces the usefulness of Controller.model in Action Pack to currently only being for documentation purposes.
2004-12-19 11:21:55 -05:00
* Added that Base.update_all and Base.delete_all return an integer of the number of affected rows #341
2004-12-22 18:56:17 -05:00
* Added scope option to validation_uniqueness #349 [Kent Sibilev]
2004-12-19 08:01:47 -05:00
2004-12-19 06:25:55 -05:00
* Added respondence to *_before_type_cast for all attributes to return their string-state before they were type casted by the column type.
This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100".
2004-12-22 18:56:17 -05:00
* Added allow_nil options to validates_inclusion_of so that validation is only triggered if the attribute is not nil [what-a-day]
* Added work-around for PostgreSQL and the problem of getting fixtures to be created from id 1 on each test case.
This only works for auto-incrementing primary keys called "id" for now #359 [Scott Baron]
* Added Base#clear_association_cache to empty all the cached associations #347 [Tobias Luetke]
2005-06-16 02:46:22 -04:00
* Added more informative exceptions in establish_connection #356 [Jeremy Kemper]
2004-12-18 10:15:27 -05:00
2004-12-17 16:51:14 -05:00
* Added Base#update_attributes that'll accept a hash of attributes and save the record (returning true if it passed validation, false otherwise).
Before:
person.attributes = @params["person"]
person.save
Now:
person.update_attributes(@params["person"])
2004-12-17 16:36:13 -05:00
* Added Base.destroy and Base.delete to remove records without holding a reference to them first.
2004-12-22 18:56:17 -05:00
* Added that query benchmarking will only happen if its going to be logged anyway #344
* Added higher_item and lower_item as public methods for acts_as_list #342 [Tobias Luetke]
2005-06-16 02:46:22 -04:00
* Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [Jeremy Kemper]
2004-12-22 18:56:17 -05:00
* Fixed that overriding an attribute's accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used
the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten]
* Fixed that Base.table_name would expect a parameter when used in has_and_belongs_to_many joins [Anna Lissa Cruz]
* Fixed that nested transactions now work by letting the outer most transaction have the responsibilty of starting and rolling back the transaction.
If any of the inner transactions swallow the exception raised, though, the transaction will not be rolled back. So always let the transaction
bubble up even when you've dealt with local issues. Closes #231 and #340.
* Fixed validates_{confirmation,acceptance}_of to only happen when the virtual attributes are not nil #348 [dpiddy@gmail.com]
* Changed the interface on AbstractAdapter to require that adapters return the number of affected rows on delete and update operations.
* Fixed the automated timestamping feature when running under Rails' development environment that resets the inheritable attributes on each request.
2004-12-17 16:36:13 -05:00
2004-12-16 14:54:04 -05:00
*1.2.0*
2004-11-23 20:04:44 -05:00
2004-12-15 22:23:06 -05:00
* Added Base.validates_inclusion_of that validates whether the value of the specified attribute is available in a particular enumerable
object. [what-a-day]
class Person < ActiveRecord::Base
validates_inclusion_of :gender, :in=>%w( m f ), :message=>"woah! what are you then!??!!"
validates_inclusion_of :age, :in=>0..99
end
2004-12-15 22:01:11 -05:00
* Added acts_as_list that can decorates an existing class with methods like move_higher/lower, move_to_top/bottom. [Tobias Luetke] Example:
2004-12-15 21:49:18 -05:00
class TodoItem < ActiveRecord::Base
acts_as_list :scope => :todo_list_id
belongs_to :todo_list
end
* Added acts_as_tree that can decorates an existing class with a many to many relationship with itself. Perfect for categories in
2004-12-15 22:01:11 -05:00
categories and the likes. [Tobias Luetke]
2004-12-15 21:49:18 -05:00
* Added that Active Records will automatically record creation and/or update timestamps of database objects if fields of the names
created_at/created_on or updated_at/updated_on are present. [Tobias Luetke]
2004-12-15 17:20:22 -05:00
* 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]
2004-12-15 10:09:44 -05:00
* Added automatic transaction block around AssociationCollection.<<, AssociationCollection.delete, and AssociationCollection.destroy_all
2004-12-15 06:55:43 -05:00
* Fixed that Base#find will return an array if given an array -- regardless of the number of elements #270 [Marten]
2004-12-14 08:55:17 -05:00
* Fixed that has_and_belongs_to_many would generate bad sql when naming conventions differed from using vanilla "id" everywhere [RedTerror]
2004-12-14 07:32:29 -05:00
* Added a better exception for when a type column is used in a table without the intention of triggering single-table inheritance. Example:
ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'bad_class!'.
This error is raised because the column 'type' is reserved for storing the class in case of inheritance.
Please rename this column if you didn't intend it to be used for storing the inheritance class or
overwrite Company.inheritance_column to use another column for that information.
* Added that single-table inheritance will only kick in if the inheritance_column (by default "type") is present. Otherwise, inheritance won't
have any magic side effects.
2004-12-12 15:37:43 -05:00
* 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]
2004-12-09 10:06:24 -05:00
* Fixed Base.errors to be indifferent as to whether strings or symbols are used. Examples:
Before:
errors.add(:name, "must be shorter") if name.size > 10
errors.on(:name) # => "must be shorter"
errors.on("name") # => nil
After:
errors.add(:name, "must be shorter") if name.size > 10
errors.on(:name) # => "must be shorter"
errors.on("name") # => "must be shorter"
2004-12-15 20:32:35 -05:00
* Added Base.validates_format_of that Validates whether the value of the specified attribute is of the correct form by matching
it against the regular expression provided. [Marcel]
class Person < ActiveRecord::Base
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :on => :create
end
2004-12-16 12:00:22 -05:00
* Added Base.validates_length_of that delegates to add_on_boundary_breaking #312 [Tobias Luetke]. Example:
Validates that the specified attribute matches the length restrictions supplied in either:
- configuration[:minimum]
- configuration[:maximum]
- configuration[:is]
- configuration[:within] (aka. configuration[:in])
Only one option can be used at a time.
class Person < ActiveRecord::Base
validates_length_of :first_name, :maximum=>30
validates_length_of :last_name, :maximum=>30, :message=>"less than %d if you don't mind"
validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name"
validates_length_of :fav_bra_size, :minimum=>1, :too_short=>"please enter at least %d character"
validates_length_of :smurf_leader, :is=>4, :message=>"papa is spelled with %d characters... don't play me."
end
2004-12-10 08:11:13 -05:00
* Added Base.validate_presence as an alternative to implementing validate and doing errors.add_on_empty yourself.
2004-12-14 20:36:05 -05:00
* Added Base.validates_uniqueness_of that alidates whether the value of the specified attributes are unique across the system.
2004-12-10 11:02:11 -05:00
Useful for making sure that only one user can be named "davidhh".
2004-12-15 07:29:08 -05:00
class Person < ActiveRecord::Base
validates_uniqueness_of :user_name
end
2004-12-10 11:02:11 -05:00
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
attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself.
2004-12-14 20:36:05 -05:00
* Added Base.validates_confirmation_of that encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example:
2004-12-09 08:37:11 -05:00
Model:
class Person < ActiveRecord::Base
2004-12-14 20:36:05 -05:00
validates_confirmation_of :password
2004-12-09 08:37:11 -05:00
end
View:
<%= password_field "person", "password" %>
<%= password_field "person", "password_confirmation" %>
The person has to already have a password attribute (a column in the people table), but the password_confirmation is virtual.
2004-12-10 08:11:13 -05:00
It exists only as an in-memory variable for validating the password. This check is performed both on create and update.
2004-12-09 08:37:11 -05:00
2004-12-09 09:37:37 -05:00
2004-12-14 20:36:05 -05:00
* 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:
2004-12-09 09:37:37 -05:00
2004-12-15 07:29:08 -05:00
class Person < ActiveRecord::Base
validates_acceptance_of :terms_of_service
end
2004-12-09 09:37:37 -05:00
2004-12-10 08:11:13 -05:00
The terms_of_service attribute is entirely virtual. No database column is needed. This check is performed both on create and update.
2004-12-09 09:37:37 -05:00
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.
2004-12-09 07:50:18 -05:00
* Added validation macros to make the stackable just like the lifecycle callbacks. Examples:
class Person < ActiveRecord::Base
validate { |record| record.errors.add("name", "too short") unless name.size > 10 }
validate { |record| record.errors.add("name", "too long") unless name.size < 20 }
validate_on_create :validate_password
private
def validate_password
errors.add("password", "too short") unless password.size > 6
end
end
2004-12-07 16:14:20 -05:00
* Added the option for sanitizing find_by_sql and the offset parts in regular finds [Sam Stephenson]. Examples:
Project.find_all ["category = ?", category_name], "created ASC", ["? OFFSET ?", 15, 20]
Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]
2004-12-07 09:48:53 -05:00
* Fixed value quoting in all generated SQL statements, so that integers are not surrounded in quotes and that all sanitation are happening
through the database's own quoting routine. This should hopefully make it lots easier for new adapters that doesn't accept '1' for integer
columns.
2004-12-07 07:33:42 -05:00
* Fixed has_and_belongs_to_many guessing of foreign key so that keys are generated correctly for models like SomeVerySpecialClient
[Florian Weber]
2005-06-16 02:46:22 -04:00
* Added counter_sql option for has_many associations [Jeremy Kemper]. Documentation:
2004-12-07 07:25:01 -05:00
<tt>:counter_sql</tt> - specify a complete SQL statement to fetch the size of the association. If +:finder_sql+ is
specified but +:counter_sql+, +:counter_sql+ will be generated by replacing SELECT ... FROM with SELECT COUNT(*) FROM.
2005-06-16 02:46:22 -04:00
* Fixed that methods wrapped in callbacks still return their original result #260 [Jeremy Kemper]
2004-12-07 07:10:57 -05:00
2004-12-07 06:15:41 -05:00
* Fixed the Inflector to handle the movie/movies pair correctly #261 [Scott Baron]
2004-12-08 05:38:10 -05:00
* Added named bind-style variable interpolation #281 [Michael Koziarski]. Example:
Person.find(["id = :id and first_name = :first_name", { :id => 5, :first_name = "bob' or 1=1" }])
2004-12-07 05:37:50 -05:00
* Added bind-style variable interpolation for the condition arrays that uses the adapter's quote method [Michael Koziarski]
Before:
find_first([ "user_name = '%s' AND password = '%s'", user_name, password ])]
find_first([ "firm_id = %s", firm_id ])] # unsafe!
After:
find_first([ "user_name = ? AND password = ?", user_name, password ])]
find_first([ "firm_id = ?", firm_id ])]
2004-12-07 05:24:13 -05:00
* Added CSV format for fixtures #272 [what-a-day]. (See the new and expanded documentation on fixtures for more information)
2004-12-06 13:56:49 -05:00
* Fixed fixtures using primary key fields called something else than "id" [dave]
2004-12-01 08:18:51 -05:00
* Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon]
2004-12-01 07:25:04 -05:00
* Added reverse order of deleting fixtures, so referential keys can be maintained #247 [Tim Bates]
2005-06-16 02:46:22 -04:00
* Added relative path search for sqlite dbfiles in database.yml (if RAILS_ROOT is defined) #233 [Jeremy Kemper]
2004-12-01 06:26:47 -05:00
2004-11-25 11:03:33 -05:00
* Added option to establish_connection where you'll be able to leave out the parameter to have it use the RAILS_ENV environment variable
2004-11-23 20:04:44 -05:00
* Fixed problems with primary keys and postgresql sequences (#230) [Tim Bates]
* Added reloading for associations under cached environments like FastCGI and mod_ruby. This makes it possible to use those environments for development.
This is turned on by default, but can be turned off with ActiveRecord::Base.reload_dependencies = false in production environments.
NOTE: This will only have an effect if you let the associations manage the requiring of model classes. All libraries loaded through
require will be "forever" cached. You can, however, use ActiveRecord::Base.load_or_require("library") to get this behavior outside of the
auto-loading associations.
* Added ERB capabilities to the fixture files for dynamic fixture generation. You don't need to do anything, just include ERB blocks like:
david:
id: 1
name: David
jamis:
id: 2
name: Jamis
<% for digit in 3..10 %>
dev_<%= digit %>:
id: <%= digit %>
name: fixture_<%= digit %>
<% end %>
* Changed the yaml fixture searcher to look in the root of the fixtures directory, so when you before could have something like:
fixtures/developers/fixtures.yaml
fixtures/accounts/fixtures.yaml
...you now need to do:
fixtures/developers.yaml
fixtures/accounts.yaml
* Changed the fixture format from:
name: david
data:
id: 1
name: David Heinemeier Hansson
birthday: 1979-10-15
profession: Systems development
---
name: steve
data:
id: 2
name: Steve Ross Kellock
birthday: 1974-09-27
profession: guy with keyboard
...to:
david:
id: 1
name: David Heinemeier Hansson
birthday: 1979-10-15
profession: Systems development
steve:
id: 2
name: Steve Ross Kellock
birthday: 1974-09-27
profession: guy with keyboard
The change is NOT backwards compatible. Fixtures written in the old YAML style needs to be rewritten!
* All associations will now attempt to require the classes that they associate to. Relieving the need for most explicit 'require' statements.
2004-12-15 21:49:18 -05:00
2004-11-23 20:04:44 -05:00
*1.1.0* (34)
* Added automatic fixture setup and instance variable availability. Fixtures can also be automatically
instantiated in instance variables relating to their names using the following style:
class FixturesTest < Test::Unit::TestCase
fixtures :developers # you can add more with comma separation
def test_developers
assert_equal 3, @developers.size # the container for all the fixtures is automatically set
assert_kind_of Developer, @david # works like @developers["david"].find
assert_equal "David Heinemeier Hansson", @david.name
end
end
* Added HasAndBelongsToManyAssociation#push_with_attributes(object, join_attributes) that can create associations in the join table with additional
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
between post and category. The added attributes will automatically be injected into objects retrieved through the association similar to the piggy-back
approach:
post.categories.push_with_attributes(category, :added_on => Date.today)
post.categories.first.added_on # => Date.today
NOTE: The categories table doesn't have a added_on column, it's the categories_post join table that does!
2005-06-16 02:46:22 -04:00
* Fixed that :exclusively_dependent and :dependent can't be activated at the same time on has_many associations [Jeremy Kemper]
2004-11-23 20:04:44 -05:00
2005-06-16 02:46:22 -04:00
* Fixed that database passwords couldn't be all numeric [Jeremy Kemper]
2004-11-23 20:04:44 -05:00
2005-06-16 02:46:22 -04:00
* Fixed that calling id would create the instance variable for new_records preventing them from being saved correctly [Jeremy Kemper]
2004-11-23 20:04:44 -05:00
* Added sanitization feature to HasManyAssociation#find_all so it works just like Base.find_all [Sam Stephenson/bitsweat]
2005-06-16 02:46:22 -04:00
* Added that you can pass overlapping ids to find without getting duplicated records back [Jeremy Kemper]
2004-11-23 20:04:44 -05:00
2005-06-16 02:46:22 -04:00
* Added that Base.benchmark returns the result of the block [Jeremy Kemper]
2004-11-23 20:04:44 -05:00
* Fixed problem with unit tests on Windows with SQLite [paterno]
* Fixed that quotes would break regular non-yaml fixtures [Dmitry Sabanin/daft]
* Fixed fixtures on windows with line endings cause problems under unix / mac [Tobias Luetke]
* Added HasAndBelongsToManyAssociation#find(id) that'll search inside the collection and find the object or record with that id
* Added :conditions option to has_and_belongs_to_many that works just like the one on all the other associations
* Added AssociationCollection#clear to remove all associations from has_many and has_and_belongs_to_many associations without destroying the records [geech]
* Added type-checking and remove in 1-instead-of-N sql statements to AssociationCollection#delete [geech]
* Added a return of self to AssociationCollection#<< so appending can be chained, like project << Milestone.create << Milestone.create [geech]
* Added Base#hash and Base#eql? which means that all of the equality using features of array and other containers now works:
[ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
* Added :uniq as an option to has_and_belongs_to_many which will automatically ensure that AssociateCollection#uniq is called
before pulling records out of the association. This is especially useful for three-way (and above) has_and_belongs_to_many associations.
* Added AssociateCollection#uniq which is especially useful for has_and_belongs_to_many associations that can include duplicates,
which is common on associations that also use metadata. Usage: post.categories.uniq
* Fixed respond_to? to use a subclass specific hash instead of an Active Record-wide one
* Fixed has_and_belongs_to_many to treat associations between classes in modules properly [Florian Weber]
* Added a NoMethod exception to be raised when query and writer methods are called for attributes that doesn't exist [geech]
* Added a more robust version of Fixtures that throws meaningful errors when on formatting issues [geech]
* Added Base#transaction as a compliment to Base.transaction for prettier use in instance methods [geech]
* Improved the speed of respond_to? by placing the dynamic methods lookup table in a hash [geech]
* Added that any additional fields added to the join table in a has_and_belongs_to_many association
will be placed as attributes when pulling records out through has_and_belongs_to_many associations.
This is helpful when have information about the association itself that you want available on retrival.
* Added better loading exception catching and RubyGems retries to the database adapters [alexeyv]
* Fixed bug with per-model transactions [daniel]
* Fixed Base#transaction so that it returns the result of the last expression in the transaction block [alexeyv]
* Added Fixture#find to find the record corresponding to the fixture id. The record
class name is guessed by using Inflector#classify (also new) on the fixture directory name.
Before: Document.find(@documents["first"]["id"])
After : @documents["first"].find
* Fixed that the table name part of column names ("TABLE.COLUMN") wasn't removed properly [Andreas Schwarz]
* Fixed a bug with Base#size when a finder_sql was used that didn't capitalize SELECT and FROM [geech]
* Fixed quoting problems on SQLite by adding quote_string to the AbstractAdapter that can be overwritten by the concrete
adapters for a call to the dbm. [Andreas Schwarz]
* Removed RubyGems backup strategy for requiring SQLite-adapter -- if people want to use gems, they're already doing it with AR.
*1.0.0 (35)*
* Added OO-style associations methods [Florian Weber]. Examples:
Project#milestones_count => Project#milestones.size
Project#build_to_milestones => Project#milestones.build
Project#create_for_milestones => Project#milestones.create
Project#find_in_milestones => Project#milestones.find
Project#find_all_in_milestones => Project#milestones.find_all
* Added serialize as a new class method to control when text attributes should be YAMLized or not. This means that automated
serialization of hashes, arrays, and so on WILL NO LONGER HAPPEN (#10). You need to do something like this:
class User < ActiveRecord::Base
serialize :settings
end
This will assume that settings is a text column and will now YAMLize any object put in that attribute. You can also specify
an optional :class_name option that'll raise an exception if a serialized object is retrieved as a descendent of a class not in
the hierarchy. Example:
class User < ActiveRecord::Base
serialize :settings, :class_name => "Hash"
end
user = User.create("settings" => %w( one two three ))
User.find(user.id).settings # => raises SerializationTypeMismatch
* Added the option to connect to a different database for one model at a time. Just call establish_connection on the class
you want to have connected to another database than Base. This will automatically also connect decendents of that class
to the different database [Renald Buter].
* Added transactional protection for Base#save. Validations can now check for values knowing that it happens in a transaction and callbacks
can raise exceptions knowing that the save will be rolled back. [Suggested by Alexey Verkhovsky]
* Added column name quoting so reserved words, such as "references", can be used as column names [Ryan Platte]
* Added the possibility to chain the return of what happened inside a logged block [geech]:
This now works:
log { ... }.map { ... }
Instead of doing:
result = []
log { result = ... }
result.map { ... }
* Added "socket" option for the MySQL adapter, so you can change it to something else than "/tmp/mysql.sock" [Anna Lissa Cruz]
* Added respond_to? answers for all the attribute methods. So if Person has a name attribute retrieved from the table schema,
person.respond_to? "name" will return true.
* Added Base.benchmark which can be used to aggregate logging and benchmark, so you can measure and represent multiple statements in a single block.
Usage (hides all the SQL calls for the individual actions and calculates total runtime for them all):
Project.benchmark("Creating project") do
project = Project.create("name" => "stuff")
project.create_manager("name" => "David")
project.milestones << Milestone.find_all
end
* Added logging of invalid SQL statements [Suggested by Daniel Von Fange]
* Added alias Errors#[] for Errors#on, so you can now say person.errors["name"] to retrieve the errors for name [Andreas Schwarz]
* Added RubyGems require attempt if sqlite-ruby is not available through regular methods.
* Added compatibility with 2.x series of sqlite-ruby drivers. [Jamis Buck]
* Added type safety for association assignments, so a ActiveRecord::AssociationTypeMismatch will be raised if you attempt to
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
mistaken association assignments. [Reported by Andreas Schwarz]
* Added the option to keep many fixtures in one single YAML document [what-a-day]
* Added the class method "inheritance_column" that can be overwritten to return the name of an alternative column than "type" for storing
the type for inheritance hierarchies. [Dave Steinberg]
* Added [] and []= as an alternative way to access attributes when the regular methods have been overwritten [Dave Steinberg]
* Added the option to observer more than one class at the time by specifying observed_class as an array
* Added auto-id propagation support for tables with arbitrary primary keys that have autogenerated sequences associated with them
on PostgreSQL. [Dave Steinberg]
* Changed that integer and floats set to "" through attributes= remain as NULL. This was especially a problem for scaffolding and postgresql. (#49)
* Changed the MySQL Adapter to rely on MySQL for its defaults for socket, host, and port [Andreas Schwarz]
* Changed ActionControllerError to decent from StandardError instead of Exception. It can now be caught by a generic rescue.
* Changed class inheritable attributes to not use eval [Caio Chassot]
* Changed Errors#add to now use "invalid" as the default message instead of true, which means full_messages work with those [Marcel Molina Jr]
* Fixed spelling on Base#add_on_boundry_breaking to Base#add_on_boundary_breaking (old naming still works) [Marcel Molina Jr.]
* Fixed that entries in the has_and_belongs_to_many join table didn't get removed when an associated object was destroyed.
* Fixed unnecessary calls to SET AUTOCOMMIT=0/1 for MySQL adapter [Andreas Schwarz]
* Fixed PostgreSQL defaults are now handled gracefully [Dave Steinberg]
* Fixed increment/decrement_counter are now atomic updates [Andreas Schwarz]
* Fixed the problems the Inflector had turning Attachment into attuchments and Cases into Casis [radsaq/Florian Gross]
* Fixed that cloned records would point attribute references on the parent object [Andreas Schwarz]
* Fixed SQL for type call on inheritance hierarchies [Caio Chassot]
* Fixed bug with typed inheritance [Florian Weber]
* Fixed a bug where has_many collection_count wouldn't use the conditions specified for that association
*0.9.5*
* Expanded the table_name guessing rules immensely [Florian Green]. Documentation:
Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending
directly from ActiveRecord. So if the hierarchy looks like: Reply < Message < ActiveRecord, then Message is used
to guess the table name from even when called on Reply. The guessing rules are as follows:
* Class name ends in "x", "ch" or "ss": "es" is appended, so a Search class becomes a searches table.
* Class name ends in "y" preceded by a consonant or "qu": The "y" is replaced with "ies",
so a Category class becomes a categories table.
* Class name ends in "fe": The "fe" is replaced with "ves", so a Wife class becomes a wives table.
* Class name ends in "lf" or "rf": The "f" is replaced with "ves", so a Half class becomes a halves table.
* Class name ends in "person": The "person" is replaced with "people", so a Salesperson class becomes a salespeople table.
* Class name ends in "man": The "man" is replaced with "men", so a Spokesman class becomes a spokesmen table.
* Class name ends in "sis": The "i" is replaced with an "e", so a Basis class becomes a bases table.
* Class name ends in "tum" or "ium": The "um" is replaced with an "a", so a Datum class becomes a data table.
* Class name ends in "child": The "child" is replaced with "children", so a NodeChild class becomes a node_children table.
* Class name ends in an "s": No additional characters are added or removed.
* Class name doesn't end in "s": An "s" is appended, so a Comment class becomes a comments table.
* Class name with word compositions: Compositions are underscored, so CreditCard class becomes a credit_cards table.
Additionally, the class-level table_name_prefix is prepended to the table_name and the table_name_suffix is appended.
So if you have "myapp_" as a prefix, the table name guess for an Account class becomes "myapp_accounts".
You can also overwrite this class method to allow for unguessable links, such as a Mouse class with a link to a
"mice" table. Example:
class Mouse < ActiveRecord::Base
def self.table_name() "mice" end
end
This conversion is now done through an external class called Inflector residing in lib/active_record/support/inflector.rb.
* Added find_all_in_collection to has_many defined collections. Works like this:
class Firm < ActiveRecord::Base
has_many :clients
end
firm.id # => 1
firm.find_all_in_clients "revenue > 1000" # SELECT * FROM clients WHERE firm_id = 1 AND revenue > 1000
[Requested by Dave Thomas]
* Fixed finders for inheritance hierarchies deeper than one level [Florian Weber]
* Added add_on_boundry_breaking to errors to accompany add_on_empty as a default validation method. It's used like this:
class Person < ActiveRecord::Base
protected
def validation
errors.add_on_boundry_breaking "password", 3..20
end
end
This will add an error to the tune of "is too short (min is 3 characters)" or "is too long (min is 20 characters)" if
the password is outside the boundry. The messages can be changed by passing a third and forth parameter as message strings.
* Implemented a clone method that works properly with AR. It returns a clone of the record that
hasn't been assigned an id yet and is treated as a new record.
* Allow for domain sockets in PostgreSQL by not assuming localhost when no host is specified [Scott Barron]
* Fixed that bignums are saved properly instead of attempted to be YAMLized [Andreas Schwartz]
* Fixed a bug in the GEM where the rdoc options weren't being passed according to spec [Chad Fowler]
* Fixed a bug with the exclusively_dependent option for has_many
*0.9.4*
* Correctly guesses the primary key when the class is inside a module [Dave Steinberg].
* Added [] and []= as alternatives to read_attribute and write_attribute [Dave Steinberg]
* has_and_belongs_to_many now accepts an :order key to determine in which order the collection is returned [radsaq].
* The ids passed to find and find_on_conditions are now automatically sanitized.
* Added escaping of plings in YAML content.
* Multi-parameter assigns where all the parameters are empty will now be set to nil instead of a new instance of their class.
* Proper type within an inheritance hierarchy is now ensured already at object initialization (instead of first at create)
*0.9.3*
* Fixed bug with using a different primary key name together with has_and_belongs_to_many [Investigation by Scott]
* Added :exclusively_dependent option to the has_many association macro. The doc reads:
If set to true all the associated object are deleted in one SQL statement without having their
before_destroy callback run. This should only be used on associations that depend solely on
this class and don't need to do any clean-up in before_destroy. The upside is that it's much
faster, especially if there's a counter_cache involved.
* Added :port key to connection options, so the PostgreSQL and MySQL adapters can connect to a database server
running on another port than the default.
* Converted the new natural singleton methods that prevented AR objects from being saved by PStore
(and hence be placed in a Rails session) to a module. [Florian Weber]
* Fixed the use of floats (was broken since 0.9.0+)
* Fixed PostgreSQL adapter so default values are displayed properly when used in conjunction with
Action Pack scaffolding.
2005-01-01 11:14:15 -05:00
* Fixed booleans support for PostgreSQL (use real true/false on boolean fields instead of 0/1 on tinyints) [radsaq]
2004-11-23 20:04:44 -05:00
*0.9.2*
* Added static method for instantly updating a record
* Treat decimal and numeric as Ruby floats [Andreas Schwartz]
* Treat chars as Ruby strings (fixes problem for Action Pack form helpers too)
* Removed debugging output accidently left in (which would screw web applications)
*0.9.1*
* Added MIT license
* Added natural object-style assignment for has_and_belongs_to_many associations. Consider the following model:
class Event < ActiveRecord::Base
has_one_and_belongs_to_many :sponsors
end
class Sponsor < ActiveRecord::Base
has_one_and_belongs_to_many :sponsors
end
Earlier, you'd have to use synthetic methods for creating associations between two objects of the above class:
roskilde_festival.add_to_sponsors(carlsberg)
roskilde_festival.remove_from_sponsors(carlsberg)
nike.add_to_events(world_cup)
nike.remove_from_events(world_cup)
Now you can use regular array-styled methods:
roskilde_festival.sponsors << carlsberg
roskilde_festival.sponsors.delete(carlsberg)
nike.events << world_cup
nike.events.delete(world_cup)
* Added delete method for has_many associations. Using this will nullify an association between the has_many and the belonging
object by setting the foreign key to null. Consider this model:
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
You could do something like:
funny_comment.has_post? # => true
announcement.comments.delete(funny_comment)
funny_comment.has_post? # => false
*0.9.0*
* Active Record is now thread safe! (So you can use it with Cerise and WEBrick applications)
[Implementation idea by Michael Neumann, debugging assistance by Jamis Buck]
* Improved performance by roughly 400% on a basic test case of pulling 100 records and querying one attribute.
This brings the tax for using Active Record instead of "riding on the metal" (using MySQL-ruby C-driver directly) down to ~50%.
Done by doing lazy type conversions and caching column information on the class-level.
* Added callback objects and procs as options for implementing the target for callback macros.
* Added "counter_cache" option to belongs_to that automates the usage of increment_counter and decrement_counter. Consider:
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
Iterating over 100 posts like this:
<% for post in @posts %>
<%= post.title %> has <%= post.comments_count %> comments
<% end %>
Will generate 100 SQL count queries -- one for each call to post.comments_count. If you instead add a "comments_count" int column
to the posts table and rewrite the comments association macro with:
class Comment < ActiveRecord::Base
belongs_to :post, :counter_cache => true
end
Those 100 SQL count queries will be reduced to zero. Beware that counter caching is only appropriate for objects that begin life
with the object it's specified to belong with and is destroyed like that as well. Typically objects where you would also specify
:dependent => true. If your objects switch from one belonging to another (like a post that can be move from one category to another),
you'll have to manage the counter yourself.
* Added natural object-style assignment for has_one and belongs_to associations. Consider the following model:
class Project < ActiveRecord::Base
has_one :manager
end
class Manager < ActiveRecord::Base
belongs_to :project
end
Earlier, assignments would work like following regardless of which way the assignment told the best story:
active_record.manager_id = david.id
Now you can do it either from the belonging side:
david.project = active_record
...or from the having side:
active_record.manager = david
If the assignment happens from the having side, the assigned object is automatically saved. So in the example above, the
project_id attribute on david would be set to the id of active_record, then david would be saved.
* Added natural object-style assignment for has_many associations [Florian Weber]. Consider the following model:
class Project < ActiveRecord::Base
has_many :milestones
end
class Milestone < ActiveRecord::Base
belongs_to :project
end
Earlier, assignments would work like following regardless of which way the assignment told the best story:
deadline.project_id = active_record.id
Now you can do it either from the belonging side:
deadline.project = active_record
...or from the having side:
active_record.milestones << deadline
The milestone is automatically saved with the new foreign key.
* API CHANGE: Attributes for text (or blob or similar) columns will now have unknown classes stored using YAML instead of using
to_s. (Known classes that won't be yamelized are: String, NilClass, TrueClass, FalseClass, Fixnum, Date, and Time).
Likewise, data pulled out of text-based attributes will be attempted converged using Yaml if they have the "--- " header.
This was primarily done to be enable the storage of hashes and arrays without wrapping them in aggregations, so now you can do:
user = User.find(1)
user.preferences = { "background" => "black", "display" => large }
user.save
User.find(1).preferences # => { "background" => "black", "display" => large }
Please note that this method should only be used when you don't care about representing the object in proper columns in
the database. A money object consisting of an amount and a currency is still a much better fit for a value object done through
aggregations than this new option.
* POSSIBLE CODE BREAKAGE: As a consequence of the lazy type conversions, it's a bad idea to reference the @attributes hash
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
new accessors for existing attributes, use read_attribute(attr_name) and write_attribute(attr_name, value) instead. Like this:
class Song < ActiveRecord::Base
# Uses an integer of seconds to hold the length of the song
def length=(minutes)
write_attribute("length", minutes * 60)
end
def length
read_attribute("length") / 60
end
end
The clever kid will notice that this opens a door to sidestep the automated type conversion by using @attributes directly.
This is not recommended as read/write_attribute may be granted additional responsibilities in the future, but if you think
you know what you're doing and aren't afraid of future consequences, this is an option.
* Applied a few minor bug fixes reported by Daniel Von Fange.
*0.8.4*
_Reflection_
* Added ActiveRecord::Reflection with a bunch of methods and classes for reflecting in aggregations and associations.
* Added Base.columns and Base.content_columns which returns arrays of column description (type, default, etc) objects.
* Added Base#attribute_names which returns an array of names for the attributes available on the object.
* Added Base#column_for_attribute(name) which returns the column description object for the named attribute.
_Misc_
* Added multi-parameter assignment:
# Instantiate objects for all attribute classes that needs more than one constructor parameter. This is done
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
# written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
# parenteses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float,
# s for String, and a for Array.
This is incredibly useful for assigning dates from HTML drop-downs of month, year, and day.
* Fixed bug with custom primary key column name and Base.find on multiple parameters.
* Fixed bug with dependent option on has_one associations if there was no associated object.
*0.8.3*
_Transactions_
* Added transactional protection for destroy (important for the new :dependent option) [Suggested by Carl Youngblood]
* Fixed so transactions are ignored on MyISAM tables for MySQL (use InnoDB to get transactions)
* Changed transactions so only exceptions will cause a rollback, not returned false.
_Mapping_
* Added support for non-integer primary keys [Aredridel/earlier work by Michael Neumann]
User.find "jdoe"
Product.find "PDKEY-INT-12"
* Added option to specify naming method for primary key column. ActiveRecord::Base.primary_key_prefix_type can either
be set to nil, :table_name, or :table_name_with_underscore. :table_name will assume that Product class has a primary key
of "productid" and :table_name_with_underscore will assume "product_id". The default nil will just give "id".
* Added an overwriteable primary_key method that'll instruct AR to the name of the
id column [Aredridele/earlier work by Guan Yang]
class Project < ActiveRecord::Base
def self.primary_key() "project_id" end
end
* Fixed that Active Records can safely associate inside and out of modules.
class MyApplication::Account < ActiveRecord::Base
has_many :clients # will look for MyApplication::Client
has_many :interests, :class_name => "Business::Interest" # will look for Business::Interest
end
* Fixed that Active Records can safely live inside modules [Aredridel]
class MyApplication::Account < ActiveRecord::Base
end
_Misc_
* Added freeze call to value object assignments to ensure they remain immutable [Spotted by Gavin Sinclair]
* Changed interface for specifying observed class in observers. Was OBSERVED_CLASS constant, now is
observed_class() class method. This is more consistant with things like self.table_name(). Works like this:
class AuditObserver < ActiveRecord::Observer
def self.observed_class() Account end
def after_update(account)
AuditTrail.new(account, "UPDATED")
end
end
[Suggested by Gavin Sinclair]
* Create new Active Record objects by setting the attributes through a block. Like this:
person = Person.new do |p|
p.name = 'Freddy'
p.age = 19
end
[Suggested by Gavin Sinclair]
*0.8.2*
* Added inheritable callback queues that can ensure that certain callback methods or inline fragments are
run throughout the entire inheritance hierarchy. Regardless of whether a descendent overwrites the callback
method:
class Topic < ActiveRecord::Base
before_destroy :destroy_author, 'puts "I'm an inline fragment"'
end
Learn more in link:classes/ActiveRecord/Callbacks.html
* Added :dependent option to has_many and has_one, which will automatically destroy associated objects when
the holder is destroyed:
class Album < ActiveRecord::Base
has_many :tracks, :dependent => true
end
All the associated tracks are destroyed when the album is.
* Added Base.create as a factory that'll create, save, and return a new object in one step.
* Automatically convert strings in config hashes to symbols for the _connection methods. This allows you
to pass the argument hashes directly from yaml. (Luke)
* Fixed the install.rb to include simple.rb [Spotted by Kevin Bullock]
* Modified block syntax to better follow our code standards outlined in
http://www.rubyonrails.org/CodingStandards
*0.8.1*
* Added object-level transactions [Thanks to Austin Ziegler for Transaction::Simple]
* Changed adapter-specific connection methods to use centralized ActiveRecord::Base.establish_connection,
which is parametized through a config hash with symbol keys instead of a regular parameter list.
This will allow for database connections to be opened in a more generic fashion. (Luke)
NOTE: This requires all *_connections to be updated! Read more in:
http://ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000081
* Fixed SQLite adapter so objects fetched from has_and_belongs_to_many have proper attributes
(t.name is now name). [Spotted by Garrett Rooney]
* Fixed SQLite adapter so dates are returned as Date objects, not Time objects [Spotted by Gavin Sinclair]
* Fixed requirement of date class, so date conversions are succesful regardless of whether you
manually require date or not.
*0.8.0*
* Added transactions
* Changed Base.find to also accept either a list (1, 5, 6) or an array of ids ([5, 7])
as parameter and then return an array of objects instead of just an object
* Fixed method has_collection? for has_and_belongs_to_many macro to behave as a
collection, not an association
* Fixed SQLite adapter so empty or nil values in columns of datetime, date, or time type
aren't treated as current time [Spotted by Gavin Sinclair]
*0.7.6*
* Fixed the install.rb to create the lib/active_record/support directory [Spotted by Gavin Sinclair]
* Fixed that has_association? would always return true [Spotted by Daniel Von Fange]