Eloy Duran
f125a34501
Define autosave association callbacks when using accepts_nested_attributes_for.
...
This way we don't define all the validation methods for all associations by
default, but only when needed.
[#3355 state:resolved]
2009-11-07 00:42:42 +01:00
José Valim
e714b499cc
Move validator, human_name and human_attribute_name to ActiveModel, remove deprecated error messages and add i18n_scope and lookup_ancestors.
...
Signed-off-by: Carl Lerche <carllerche@mac.com >
2009-10-20 17:52:32 -07:00
Yehuda Katz + Carl Lerche
4f6d6f7031
Have all the tests running off a single Gemfile
2009-10-20 16:34:44 -07:00
Jeremy Kemper
2767036392
Use bundled env for tests only
2009-10-19 19:00:48 -07:00
Eric Chapweske
2831996483
Fixed: #without_typecast should only disable typecasting on the duplicated attributes [ #3387 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-10-18 10:22:22 -05:00
Eric Chapweske
f936a1f100
Refactoring attributes/types [ #3348 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-10-17 12:37:15 -05:00
Nick Sieger
471a394215
Modify connection pool callbacks to be compatible w/ new style
...
Signed-off-by: Yehuda Katz <wycats@gmail.com >
2009-10-16 10:34:52 -07:00
José Valim
a15e02d44a
Unify benchmark APIs.
2009-10-15 18:19:25 -03:00
Jeremy Kemper
9c52f96acb
Include bundled env in toplevel require, if present
2009-10-14 19:15:33 -07:00
Jeremy Kemper
4cbd3f050b
Move from git submodule to gem bundle
2009-10-14 17:19:24 -07:00
Emilio Tagua
991d1bc200
Merge commit 'rails/master'
2009-10-13 15:06:43 -03:00
Pratik Naik
68d416a58f
Add a :limit option to specify the maximum number of records that can be processed by accepts_nested_attributes_for
2009-10-09 16:08:11 +01:00
Pratik Naik
e94caf0788
Store entire options hash in the class var rather than just the reject_if proc for the nested attributes
2009-10-09 15:47:10 +01:00
Emilio Tagua
0cf4662ec5
Merge commit 'rails/master'
2009-10-08 15:05:18 -03:00
Pratik Naik
0c27d0886e
Use indifferent access attributes instead of stringifying them
2009-10-08 00:15:36 +01:00
Pratik Naik
572323135f
Allow accepts_nested_attributes_for :reject_if option accept symbols for using a method
...
Conflicts:
activerecord/lib/active_record/nested_attributes.rb
2009-10-07 23:50:30 +01:00
Emilio Tagua
9a958a3d7d
Relations: Added offset when finding with associations. Delegate array instance
...
methods to to_a.
2009-10-07 12:43:04 -03:00
Emilio Tagua
aadb09b13b
Merge commit 'rails/master'
2009-10-07 12:23:23 -03:00
Emilio Tagua
1d5854826b
Allow preload and eager_load to work on relations at the same time.
2009-10-07 11:57:59 -03:00
Paul Gillard
6361d4234c
Call initialize_copy when cloning [ #3164 state:resolved]
...
Cloned AR objects are now instantiated through initialize_copy rather than
new/initialize. This allows AR classes to override initialize_copy in order to
implement deep cloning.
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-10-06 16:25:51 -05:00
Emilio Tagua
1daceeb838
Merge branch 'associations_2'
2009-10-05 15:25:06 -03:00
Emilio Tagua
65f055a3ed
Added eager loading support to Relation and ActiveRecord#all.
2009-10-05 15:24:08 -03:00
Emilio Tagua
3747f896a1
Moved relation's test to relation_test.
2009-10-05 14:39:20 -03:00
Emilio Tagua
29457a21c0
Merge commit 'rails/master'
2009-10-02 10:52:55 -03:00
Luciano G Panaro
4168f87623
Make has_one with :conditions hash scope build or creation of the associated object with those conditions
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#3088 state:committed]
2009-09-28 14:50:33 +13:00
Emilio Tagua
a294d8362b
Merge commit 'rails/master'
2009-09-21 14:57:24 -03:00
Justin Bailey
c9d3c48dc6
Enable use of MySQL stored procedures by default.
...
[#3204 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-09-17 10:57:03 -07:00
Emilio Tagua
24260dc0c8
Merge commit 'rails/master'
2009-09-14 09:47:55 -03:00
Eloy Duran
26639e8a45
Removed the version of ActiveRecord::Base#destroyed? that was added in a44a1257d8.
...
Because José Valim was cheeky enough to already add it to the master branch.
2009-09-12 16:16:48 +02:00
Alexey Kovyrin
938c0ee045
Define autosave association validation methods only when needed. [ #3161 state:resolved]
...
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com >
2009-09-12 16:04:36 +02:00
Eloy Duran
65f98951ac
During autosave, ignore records that already have been destroyed. [ #2537 state:resolved]
2009-09-12 16:04:07 +02:00
Graeme Porteous
c01be9de32
Fix has_one with foreign_key and primary_key association bug which caused the associated object being lost when saving the owner. [ #1756 state:resolved]
...
Mixed in a bit from patch by ransom-briggs. [#2813 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com >
2009-09-12 16:03:32 +02:00
José Valim
3091252aba
Rename nested attributes _delete to _destroy to reflect its actual behavior and DSL (:allow_destroy). Deprecation warning added. [ #2889 state:resolved]
...
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com >
2009-09-12 15:59:32 +02:00
Dmitry Polushkin
845f62f473
Fix autosave association to skip validation if it is marked for destruction. [ #2064 state:resolved]
...
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com >
2009-09-12 15:56:01 +02:00
Eloy Duran
6cc0b9638f
Explicitely setting `autosave => false' should override new_record autosaving. [ #2214 state:resolved]
...
Original author is Jacob.
2009-09-12 15:53:15 +02:00
Lance Ivy
a44a1257d8
Don't cascade autosave validation to destroyed children. [ #2761 state:resolved]
...
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com >
2009-09-12 15:40:45 +02:00
Mike Breen
bcd0ef710e
Raise an exception with friendlier error message when attempting to build a polymorphic belongs_to with accepts_nested_attributes_for. [ #2318 state:resolved]
...
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com >
2009-09-12 15:37:54 +02:00
Akira Matsuda
68b2b730e4
Fix default_error_messages back to the original message
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-09-11 18:34:12 -07:00
Emilio Tagua
0489f0c582
Merge commit 'rails/master'
2009-09-08 15:39:33 -03:00
Emilio Tagua
670281c6b2
Merge commit 'rails/master'
...
Conflicts:
activerecord/lib/active_record/associations.rb
2009-09-08 15:38:51 -03:00
José Valim
2ea1d684d9
Refactor new callbacks and AR implementation.
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-09-08 10:26:39 -05:00
José Valim
4f37b97033
Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed.
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-09-08 10:26:39 -05:00
Jeremy Kemper
3b6a9a020e
Revert "Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted."
...
Test failures on PostgreSQL.
[#3128 state:open]
This reverts commit da636809da .
2009-09-02 13:55:47 -07:00
Jeffrey Hardy
41b3c912b7
Remove ClassInheritableAttributes test case, already covered by ActiveSupport [ #3114 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-09-02 11:21:20 -05:00
Emilio Tagua
39e4e76d15
Merge commit 'rails/master'
...
Conflicts:
activerecord/lib/active_record/associations.rb
2009-09-01 15:45:43 -03:00
Emilio Tagua
c01c21b31d
Added association preload to relation.
2009-09-01 15:36:09 -03:00
José Valim
da636809da
Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted.
...
[#3128 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-09-01 10:15:23 -07:00
Josh Sharpe
80989437dc
I added this feature so that a Map of changed fields could be retrieved
...
after a model had been saved. This is useful in the after_save callback
when you need to know what fields changed. At present there is no way
to do this other than have code in the before_save callback that takes
a copy of the changes Map, which I thought was a bit messy.
Example.
person = Person.find_by_name('bob')
person.name = 'robert'
person.changes # => {'name' => ['bob, 'robert']}
person.save
person.changes # => {}
person.previous_changes # => {'name' => ['bob, 'robert']}
person.reload
person.previous_changes # => {}
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-08-31 12:50:27 -05:00
Emilio Tagua
6b67df70ab
Revert "Revert "Add readonly support for relations.""
...
This reverts commit f2c0725d79 .
2009-08-27 20:03:46 -03:00
Emilio Tagua
f2c0725d79
Revert "Add readonly support for relations."
...
This reverts commit 7cce95b25a .
2009-08-27 20:00:14 -03:00