Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | extract cache counter logic to one method | Aaron Patterson | 2013-12-12 | 1 | -11/+10 |
| | |||||
* | remove duplicate code | Aaron Patterson | 2013-12-12 | 1 | -15/+6 |
| | |||||
* | extract a method for updating without a record object | Aaron Patterson | 2013-12-12 | 1 | -6/+10 |
| | |||||
* | extract methods out of the cache update method | Aaron Patterson | 2013-12-12 | 1 | -14/+22 |
| | |||||
* | pull a nil check up one frame | Aaron Patterson | 2013-12-12 | 1 | -6/+10 |
| | |||||
* | remove more nil checks | Aaron Patterson | 2013-12-12 | 1 | -6/+5 |
| | |||||
* | remove nil check | Aaron Patterson | 2013-12-12 | 1 | -6/+10 |
| | | | | | calling replace_keys could possibly do a nil check twice, this commit reduces it to once. | ||||
* | remove the nil check from set_inverse_instance | Aaron Patterson | 2013-12-12 | 1 | -1/+1 |
| | | | | | methods that call set_inverse_instance with a record will not have to pay the cost of a nil check on every call | ||||
* | Remove useless comment and white spaces :scissors: [ci skip] | Carlos Antonio da Silva | 2013-09-01 | 1 | -2/+2 |
| | |||||
* | Adding a bang to method name of raise_on_type_mismatch. | wangjohn | 2013-03-21 | 1 | -1/+1 |
| | |||||
* | BELONGS TO ASSOCIATION | Typo fix | libin | 2013-02-25 | 1 | -1/+1 |
| | |||||
* | improved different_target conditions | Angelo Capilleri | 2013-01-08 | 1 | -2/+5 |
| | |||||
* | move dependency logic out of generated methods | Jon Leighton | 2012-08-10 | 1 | -0/+5 |
| | |||||
* | @stale_state should be nil when a model isn't saved. | kennyj | 2012-04-13 | 1 | -1/+1 |
| | |||||
* | Some refactor for association. | kennyj | 2012-04-12 | 1 | -0/+5 |
| | | | | | | | * Remove unused association_class method. * Remove a unnecessary assignment. * Move @updated to BelongsToAssociation that only reference this instance variable. * Reset @stale_state at the reset method. I think this place is right place. | ||||
* | Fix belongs_to polymorphic with custom primary key on target. | Jon Leighton | 2011-09-26 | 1 | -1/+5 |
| | | | | Closes #3104. | ||||
* | Don't find belongs_to target when the foreign_key is NULL. Fixes #2828 | Georg Friedrich | 2011-09-05 | 1 | -0/+4 |
| | |||||
* | Fix exception if old and new targets are both nil. Fixes #1471. | Jon Leighton | 2011-07-12 | 1 | -1/+1 |
| | |||||
* | Rename target_klass to klass | Jon Leighton | 2011-02-21 | 1 | -1/+1 |
| | |||||
* | Delegate Association#options to the reflection, and replace ↵ | Jon Leighton | 2011-02-21 | 1 | -1/+1 |
| | | | | 'reflection.options' with 'options'. Also add through_options and source_options methods for through associations. | ||||
* | Singular associations no longer use a proxy, so no need to check for the ↵ | Jon Leighton | 2011-02-21 | 1 | -1/+1 |
| | | | | proxy type on assignment. | ||||
* | Associations - where possible, call attributes methods rather than directly ↵ | Jon Leighton | 2011-02-21 | 1 | -10/+10 |
| | | | | accessing the instance variables | ||||
* | Let's be less blasé about method visibility on association proxies | Jon Leighton | 2011-01-30 | 1 | -0/+1 |
| | |||||
* | find_target can also go into SingularAssociation | Jon Leighton | 2011-01-16 | 1 | -4/+0 |
| | |||||
* | Abstract a bit more into SingularAssociation | Jon Leighton | 2011-01-16 | 1 | -2/+1 |
| | |||||
* | Use self.target= rather than @target= as the former automatically sets loaded | Jon Leighton | 2011-01-16 | 1 | -3/+1 |
| | |||||
* | Abstract common code from BelongsToAssociation and HasOneAssociation into ↵ | Jon Leighton | 2011-01-16 | 1 | -19/+1 |
| | | | | SingularAssociation | ||||
* | belongs_to records should be initialized within the association scope | Jon Leighton | 2011-01-16 | 1 | -2/+8 |
| | |||||
* | Add create_association! for belongs_to | Jon Leighton | 2011-01-16 | 1 | -0/+4 |
| | |||||
* | reduce funcalls by using falsey objects | Aaron Patterson | 2011-01-14 | 1 | -2/+2 |
| | |||||
* | Construct an actual ActiveRecord::Relation object for the association scope, ↵ | Jon Leighton | 2011-01-07 | 1 | -17/+0 |
| | | | | 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. | ||||
* | When preloading a belongs_to, the target should still be set (to nil) if ↵ | Jon Leighton | 2011-01-03 | 1 | -3/+1 |
| | | | | there is no foreign key present. And the loaded flag should be set on the association proxy. This then allows us to remove the foreign_key_present? check from BelongsToAssociation#find_target. Also added a test for the same thing on polymorphic associations. | ||||
* | Create the association scope directly rather than going through with_scope | Jon Leighton | 2011-01-03 | 1 | -1/+1 |
| | |||||
* | Rename AssociationProxy#foreign_key_present to foreign_key_present? | Jon Leighton | 2011-01-03 | 1 | -3/+3 |
| | |||||
* | Allow assignment on has_one :through where the owner is a new record [#5137 ↵ | Jon Leighton | 2011-01-03 | 1 | -11/+4 |
| | | | | | | | | | | 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! | ||||
* | Rename AssociationReflection#primary_key_name to foreign_key, since the ↵ | Jon Leighton | 2010-12-31 | 1 | -7/+7 |
| | | | | options key which it relates to is :foreign_key | ||||
* | Support for :counter_cache on polymorphic belongs_to | Jon Leighton | 2010-12-31 | 1 | -1/+1 |
| | |||||
* | Refactor BelongsToAssociation to allow BelongsToPolymorphicAssociation to ↵ | Jon Leighton | 2010-12-31 | 1 | -49/+55 |
| | | | | inherit from it | ||||
* | Refactor we_can_set_the_inverse_on_this? to use a less bizarre name amongst ↵ | Jon Leighton | 2010-12-26 | 1 | -4/+5 |
| | | | | other things | ||||
* | If a has_many goes :through a belongs_to, and the foreign key of the ↵ | Jon Leighton | 2010-12-23 | 1 | -1/+4 |
| | | | | belongs_to changes, then the has_many should be considered stale. | ||||
* | Improved strategy for updating a belongs_to association when the foreign key ↵ | Jon Leighton | 2010-12-23 | 1 | -0/+8 |
| | | | | 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. | ||||
* | removing space error | Aaron Patterson | 2010-11-22 | 1 | -1/+1 |
| | |||||
* | use persisted? instead of new_record? wherever possible | David Chelimsky | 2010-11-09 | 1 | -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> | ||||
* | Refactoring: replace the mix of variables like @finder_sql, @counter_sql, ↵ | Jon Leighton | 2010-10-30 | 1 | -9/+11 |
| | | | | 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. | ||||
* | dry up the hash dup and avoid sending nil values | Aaron Patterson | 2010-08-11 | 1 | -4/+8 |
| | |||||
* | Don't increment and then decrement the same counter when re-assigning a ↵ | Tarmo Tänav | 2010-07-29 | 1 | -1/+1 |
| | | | | | | | | belongs_to association [#2786 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com> | ||||
* | Adds title to activerecord/lib/active_record/associations/* | Rizwan Reza | 2010-06-16 | 1 | -0/+1 |
| | |||||
* | Remove whitespace. | Emilio Tagua | 2009-08-19 | 1 | -2/+2 |
| | |||||
* | Add primary_key option to belongs_to association | Szymon Nowak | 2009-07-15 | 1 | -4/+22 |
| | | | | | | [#765 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net> | ||||
* | Providing support for :inverse_of as an option to associations. | Murray Steele | 2009-05-04 | 1 | -1/+11 |
| | | | | | | | | | | | | | | | | | | | | | | 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> |