Vijay Dev
bd84b2bb5d
Merge branch 'master' of github.com:lifo/docrails
2011-12-16 23:34:00 +05:30
Jon Leighton
909b337da8
Don't try to autosave nested assocs. Fixes #2961 .
2011-12-14 17:28:59 +00:00
Alexander
9e39dc48d6
Update activerecord/lib/active_record/reflection.rb
2011-12-14 20:53:39 +04:00
Jon Leighton
e6cc2ea201
Allow the :class_name option for associations to take a symbol.
...
This is to avoid confusing newbies, and to be consistent with the fact
that other options like :foreign_key already allow a symbol or a string.
2011-11-04 11:17:56 +00:00
Jon Leighton
d486103570
Fix #3271 .
...
Building the conditions of a nested through association could
potentially modify the conditions of the through and/or source
association.
This is a Bad Thing.
2011-11-03 15:12:08 +00:00
Jon Leighton
2e9e647fee
Raise an exception on unknown primary key inside AssociationReflection.
...
An association between two models cannot be made if a relevant key is
unknown, so fail fast rather than generating invalid SQL. Fixes #3207 .
2011-10-05 20:21:21 +01:00
Jon Leighton
adb8ac153f
Don't call self.class unless necessary. Closes #3171 .
2011-09-29 18:00:30 +01:00
Jon Leighton
3b87c38d02
Fix belongs_to polymorphic with custom primary key on target.
...
Closes #3104 .
2011-09-26 15:42:34 +01:00
Jon Leighton
b24d668859
Ensure we are not comparing a string with a symbol in HasManyAssociation#inverse_updates_counter_cache?. Fixes #2755 , where a counter cache could be decremented twice as far as it was supposed to be.
2011-09-06 15:58:07 +01:00
Aaron Patterson
2ed8097058
calling super is super. if the other object is exactly equal, we can return early
2011-07-01 14:38:22 -07:00
Jon Leighton
cb99c8593a
Remove AssociationReflection#create_association and AssociationReflection#create_association! - they are not called from anywhere.
2011-06-30 23:39:58 +01:00
Jon Leighton
0e225ec583
Assign the association attributes to the associated record before the before_initialize callback of the record runs. Fixes #1842 .
2011-06-30 23:39:58 +01:00
Aaron Patterson
f261ef42cc
cache the plural name on the reflection so we do not pay pluralize costs on joins
2011-06-30 15:31:22 -07:00
Xavier Noria
b7921f50e7
Merge branch 'master' of github.com:rails/rails
2011-05-25 22:49:23 +02:00
Xavier Noria
00e1d0832e
Merge branch 'master' of git://github.com/lifo/docrails
...
Conflicts:
actionmailer/lib/action_mailer/base.rb
activesupport/lib/active_support/core_ext/kernel/requires.rb
2011-05-25 22:48:47 +02:00
Josh Kalderimis
542114e1d8
removed deprecated methods, and related tests, from ActiveRecord
2011-05-25 02:29:32 +02:00
Sebastian Martinez
0034b7822d
Remove extra white spaces on ActiveRecord docs.
2011-05-23 20:58:25 -03:00
Jon Leighton
d7a910e31e
Fix problem with loading polymorphic associations which have been defined in an abstract superclass. Fixes #552 .
2011-05-22 21:25:02 +01:00
Prem Sichanugrist
733bfa63f5
Remove #among? from Active Support
...
After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now.
It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
2011-04-13 20:25:28 +08:00
David Heinemeier Hansson
d1575ae1b9
Change Object#either? to Object#among? -- thanks to @jamesarosen for the suggestion!
2011-04-12 00:23:07 +02:00
Prem Sichanugrist
a9f3c9da01
Using Object#in? and Object#either? in various places
...
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
2011-04-11 03:17:09 +08:00
Jon Leighton
39a6f4f25d
Simplify implementation of ThroughReflection#chain
2011-03-11 00:51:57 +00:00
Jon Leighton
2d3d9e3531
Rename Reflection#through_reflection_chain and #through_options to Reflection#chain and Reflection#options as they now no longer relate solely to through associations.
2011-03-10 19:28:26 +00:00
Jon Leighton
6490d65234
Move the code which builds a scope for through associations into a generic AssociationScope class which is capable of building a scope for any association.
2011-03-10 19:04:00 +00:00
Jon Leighton
bb063b2f1b
Fix test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys
2011-03-07 20:58:32 +00:00
Jon Leighton
5dc1fb39dd
Refactor ThroughAssociation#join_to to be much smaller, and independent of construct_owner_conditions.
2011-03-06 23:38:10 +00:00
Jon Leighton
7fddb94262
Push source_type and polymorphic conditions out of ThroughAssociation and JoinDependency::JoinAssociation and into the reflection instead.
2011-03-05 22:07:30 +00:00
Jon Leighton
ddf83d14f1
Add a test for STI on the through where the through is nested, and change the code which support this
2011-03-05 20:10:24 +00:00
Jon Leighton
735844db71
Merge branch 'master' into nested_has_many_through
...
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/association_preload.rb
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations/class_methods/join_dependency.rb
activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
activerecord/lib/active_record/associations/has_many_association.rb
activerecord/lib/active_record/associations/has_many_through_association.rb
activerecord/lib/active_record/associations/has_one_association.rb
activerecord/lib/active_record/associations/has_one_through_association.rb
activerecord/lib/active_record/associations/through_association_scope.rb
activerecord/lib/active_record/reflection.rb
activerecord/test/cases/associations/has_many_through_associations_test.rb
activerecord/test/cases/associations/has_one_through_associations_test.rb
activerecord/test/cases/reflection_test.rb
activerecord/test/cases/relations_test.rb
activerecord/test/fixtures/memberships.yml
activerecord/test/models/categorization.rb
activerecord/test/models/category.rb
activerecord/test/models/member.rb
activerecord/test/models/reference.rb
activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
Jon Leighton
d90b4e2615
Rewrote AssociationPreload.
2011-02-28 22:12:34 +00:00
Jon Leighton
32eef69dc1
Delegate Association#options to the reflection, and replace 'reflection.options' with 'options'. Also add through_options and source_options methods for through associations.
2011-02-21 10:16:14 -08:00
Jon Leighton
1644663ba7
Split AssociationProxy into an Association class (and subclasses) which manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
2011-02-18 00:00:13 +00:00
Jon Leighton
f0b9805029
Ensure that association_ids uses the correct attribute where the association is a has_many :through with a :primary_key option on the source reflection. [ #6376 state:resolved]
2011-02-18 00:00:13 +00:00
Jon Leighton
3b797c8c86
DRY up the code which instantiates the association proxy
2011-01-11 13:45:08 -08:00
Jon Leighton
0619dc2319
Implement deprecated version of AssociationReflection#primary_key_name, which has been renamed to #foreign_key. Also bumping the deprecation_horizon in Active Support to 3.1.
2011-01-03 16:24:32 -08:00
Jon Leighton
c47f802d0e
Have a proper AssociationReflection#foreign_type method rather than using options[:foreign_type]
2011-01-03 16:24:31 -08:00
Jon Leighton
1267598881
Rename AssociationReflection#primary_key_name to foreign_key, since the options key which it relates to is :foreign_key
2010-12-31 20:00:45 +00:00
Jon Leighton
b0bb911fa1
Now we can drop-kick AssociationReflection#dependent_conditions into oblivion.
2010-12-31 20:00:44 +00:00
Jon Leighton
fb3a8c51b4
Raise an error for associations which try to go :through a polymorphic association [ #6212 state:resolved]
2010-12-23 15:19:18 -08:00
Jon Leighton
2d9626fc74
Improved strategy for updating a belongs_to association when the foreign key changes. Rather than resetting each affected association when the foreign key changes, we should lazily check for 'staleness' (where fk does not match target id) when the association is accessed.
2010-12-23 15:19:18 -08:00
Jon Leighton
c6db37e69b
Don't allow a has_one association to go :through a collection association [ #2976 state:resolved]
2010-12-23 15:19:17 -08:00
Jon Leighton
b8153fd5a1
Fix problem where wrong keys are used in JoinAssociation when an association goes :through a belongs_to [ #2801 state:resolved]
2010-12-20 13:56:04 -08:00
Jon Leighton
14b880fd03
Fix various issues with the :primary_key option in :through associations [ #2421 state:resolved]
2010-12-15 17:50:14 -08:00
Aaron Patterson
b3ae67dbb9
reduce method calls
2010-12-16 01:49:28 +05:30
Jon Leighton
9a98c766e0
Merge branch 'master' into nested_has_many_through
...
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/associations/class_methods/join_dependency.rb
activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
activerecord/lib/active_record/associations/has_many_through_association.rb
2010-12-12 09:55:32 +00:00
Aaron Patterson
9e16254b46
reduce method calls
2010-12-10 16:31:09 -08:00
Jon Leighton
3a7f43ca6e
Merge branch 'master' into nested_has_many_through
...
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/associations.rb
2010-11-27 11:31:17 +00:00
Josh Kalderimis
d7db6a8873
class inheritable attributes is used no more! all internal use of class inheritable has been changed to class_attribute. class inheritable attributes has been deprecated.
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-11-20 19:40:29 +01:00
Jon Leighton
9a1a32ac2b
Fix naughty trailing whitespace
2010-10-31 11:21:28 +00:00
Jon Leighton
fc276e5635
Merge branch 'master' into nested_has_many_through
...
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/association_preload.rb
activerecord/lib/active_record/associations.rb
activerecord/test/schema/schema.rb
2010-10-28 18:06:01 +01:00