aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/association_proxy.rb
Commit message (Collapse)AuthorAgeFilesLines
* Rename AssociationProxy#loaded to loaded! as it mutates the associationJon Leighton2011-01-301-3/+3
|
* Abstract load_target conditional logicJon Leighton2011-01-301-5/+6
|
* Remove unused methods conditions, sql_conditions and sanitize_sqlJon Leighton2011-01-301-12/+0
|
* Let's be less blasé about method visibility on association proxiesJon Leighton2011-01-301-51/+54
|
* Abstract common code from BelongsToAssociation and HasOneAssociation into ↵Jon Leighton2011-01-161-4/+5
| | | | SingularAssociation
* write the delegate method directly to avoid `delegate` callstack overheadAaron Patterson2011-01-141-1/+5
|
* reduce some lasignsAaron Patterson2011-01-141-2/+1
|
* just use return value of load_targetAaron Patterson2011-01-121-2/+1
|
* just call methods on return value of `load_target`Aaron Patterson2011-01-121-8/+3
|
* default return value is nilAaron Patterson2011-01-121-1/+0
|
* @loaded is defined in initialize, so we should not need thisAaron Patterson2011-01-121-2/+0
|
* just use respond_to? and super rather than aliasing around methodsAaron Patterson2011-01-121-4/+3
|
* adding a test for no method errorAaron Patterson2011-01-111-11/+5
|
* Get rid of set_association_target and association_loaded? as the parts of ↵Jon Leighton2011-01-111-1/+2
| | | | the code that need that can now just use association_proxy(:name).loaded?/target=
* We can use the association_proxy method directly in HasOneThroughAssociation nowJon Leighton2011-01-111-17/+18
|
* Not really worth having the HasAssociation module for just a single methodJon Leighton2011-01-071-2/+9
|
* Construct an actual ActiveRecord::Relation object for the association scope, ↵Jon Leighton2011-01-071-16/+42
| | | | rather than a hash which is passed to apply_finder_options. This allows more flexibility in how the scope is created, for example because scope.where(a, b) and scope.where(a).where(b) mean different things.
* use attr_reader and alias methods to access instance variablesAaron Patterson2011-01-051-8/+4
|
* Create the association scope directly rather than going through with_scopeJon Leighton2011-01-031-16/+20
|
* Let AssociationCollection#find use #scoped to do its finding. Note that I am ↵Jon Leighton2011-01-031-14/+0
| | | | removing test_polymorphic_has_many_going_through_join_model_with_disabled_include, since this specifies different behaviour for an association than for a regular scope. It seems reasonable to expect scopes and association proxies to behave in roughly the same way rather than having subtle differences.
* Rename AssociationProxy#foreign_key_present to foreign_key_present?Jon Leighton2011-01-031-2/+2
|
* Allow assignment on has_one :through where the owner is a new record [#5137 ↵Jon Leighton2011-01-031-9/+22
| | | | | | | | | | state:resolved] This required changing the code to keep the association proxy for a belongs_to around, despite its target being nil. Which in turn required various changes to the way that stale target checking is handled, in order to support various edge cases (loaded target is nil then foreign key added, foreign key is changed and then changed back, etc). A side effect is that the code is nicer and more succinct. Note that I am removing test_no_unexpected_aliasing since that is basically checking that the proxy for a belongs_to *does* change, which is the exact opposite of the intention of this commit. Also adding various tests for various edge cases and related things. Phew, long commit message!
* Refactor BelongsToAssociation to allow BelongsToPolymorphicAssociation to ↵Jon Leighton2010-12-311-8/+23
| | | | inherit from it
* And owner_quoted_id can go tooJon Leighton2010-12-311-5/+0
|
* Refactor we_can_set_the_inverse_on_this? to use a less bizarre name amongst ↵Jon Leighton2010-12-261-9/+15
| | | | other things
* Add a HasAssociation module for common code for has_* associationsJon Leighton2010-12-261-54/+5
|
* Remove AssociationProxy#dependent? - it's badly named and only used in one placeJon Leighton2010-12-261-5/+0
|
* Associations: DRY up the code which is generating conditions, and make it ↵Jon Leighton2010-12-261-9/+36
| | | | all use arel rather than SQL strings
* Improved strategy for updating a belongs_to association when the foreign key ↵Jon Leighton2010-12-231-0/+10
| | | | 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.
* Partialy revert f1c13b0dd7b22b5f6289ca1a09f1d7a8c7c8584bJosé Valim2010-11-281-1/+1
|
* removing space errorsAaron Patterson2010-11-161-2/+2
|
* use persisted? instead of new_record? wherever possibleDavid Chelimsky2010-11-091-3/+3
| | | | | | | | | | | - persisted? is the API defined in ActiveModel - makes it easier for extension libraries to conform to ActiveModel APIs without concern for whether the extended object is specifically ActiveRecord [#5927 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Association Proxy should not undefine the default respond_to_missingsblackstone2010-11-041-1/+1
|
* Refactoring: replace the mix of variables like @finder_sql, @counter_sql, ↵Jon Leighton2010-10-301-0/+19
| | | | etc with just a single scope hash (created on initialization of the proxy). This is now used consistently across all associations. Therefore, all you have to do to ensure finding/counting etc is done correctly is implement the scope correctly.
* Adds title to activerecord/lib/active_record/associations/*Rizwan Reza2010-06-161-0/+2
|
* Revert "removing the extra \"Neeraj Singh2010-06-151-1/+1
| | | | This reverts commit 51a9703b1e80caa30d699f30615f023079874623.
* removing the extra \Neeraj Singh2010-06-151-1/+1
|
* Prevent calling regexp on symbol in Ruby 1.9 in association_proxyErnie Miller2010-05-051-1/+1
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Avoid deprecated String#to_a by using Array.wrap(...) instead of Array(...)Jeremy Kemper2010-04-101-1/+3
|
* fisting uninitialized ivar warnings. [#4198 state:resolved]Aaron Patterson2010-03-161-0/+1
| | | | Signed-off-by: wycats <wycats@gmail.com>
* keep AssociationProxy#to_a to avoid warning in Array(post.author), and ↵Xavier Noria2010-03-121-1/+1
| | | | | | | | delegate it to @target in association collections [#4165 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Make sure association proxy does not pass quoted table name to sanitize_sqlPratik Naik2010-01-011-1/+1
|
* Revert "Fix instance_eval calls to association proxies"Joshua Peek2009-12-121-2/+6
| | | | | | | | | | I think it may of broke the build. Lets see. This reverts commit 49e943c4f0ac3459bd53023167aaa08fc8e46733. Conflicts: activerecord/test/cases/associations/has_many_associations_test.rb
* Fix instance_eval calls to association proxiesMat Brown2009-12-021-6/+2
| | | | | | | | In the current stable, ActiveRecord::Associations::AssociationProxy#method_missing calls yield() if a block is given, causing the block to always be evaluated in its calling context. However, in the case of instance_eval, correct behavior requires that the block be passed directly to the @target, rather than being evaluated inside a different block. Incidentally, this also simplifies the code slightly. [#3412 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Ruby 1.9.2: use recursive flattenJeremy Kemper2009-11-141-7/+1
|
* Ruby 1.9.2: fix flatten_deeper to preserve nilsJeremy Kemper2009-11-141-1/+1
|
* Ruby 1.9.2: avoid #flattenJeremy Kemper2009-11-131-4/+16
|
* Remove unused quoted_record_ids, now ARel does this using ARel::In.Emilio Tagua2009-08-181-9/+0
|
* Providing support for :inverse_of as an option to associations.Murray Steele2009-05-041-0/+14
| | | | | | | | | | | | | | | | | | | | | | You can now add an :inverse_of option to has_one, has_many and belongs_to associations. This is best described with an example: class Man < ActiveRecord::Base has_one :face, :inverse_of => :man end class Face < ActiveRecord::Base belongs_to :man, :inverse_of => :face end m = Man.first f = m.face Without :inverse_of m and f.man would be different instances of the same object (f.man being pulled from the database again). With these new :inverse_of options m and f.man are the same in memory instance. Currently :inverse_of supports has_one and has_many (but not the :through variants) associations. It also supplies inverse support for belongs_to associations where the inverse is a has_one and it's not a polymorphic. Signed-off-by: Murray Steele <muz@h-lame.com> Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Ensure JoinAssociation uses aliased table name when multiple associations ↵Pratik Naik2009-04-201-2/+2
| | | | have hash conditions on the same table