Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Use frozen-string-literal in ActiveRecord | Kir Shatrov | 2017-07-19 | 1 | -0/+2 |
| | |||||
* | Revert "Merge pull request #29540 from kirs/rubocop-frozen-string" | Matthew Draper | 2017-07-02 | 1 | -1/+0 |
| | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa. | ||||
* | Enforce frozen string in Rubocop | Kir Shatrov | 2017-07-01 | 1 | -0/+1 |
| | |||||
* | Evaluate belongs_to :default option against the owner, not the association | George Claghorn | 2017-04-27 | 1 | -1/+1 |
| | |||||
* | Evaluate the default block only when necessary | Ryuta Kamizono | 2017-03-20 | 1 | -2/+2 |
| | | | | Follow up of #28453. | ||||
* | Add :default option to belongs_to (#28453) | George Claghorn | 2017-03-17 | 1 | -0/+4 |
| | | | | | | | | | | | Use it to specify that an association should be initialized with a particular record before validation. For example: # Before belongs_to :account before_validation -> { self.account ||= Current.account } # After belongs_to :account, default: -> { Current.account } | ||||
* | applies remaining conventions across the project | Xavier Noria | 2016-08-06 | 1 | -1/+0 |
| | |||||
* | Fix counter_cache double increment bug | Tom Kadwill | 2016-04-28 | 1 | -0/+1 |
| | |||||
* | Make #increment! and #decrement! methods concurency safe | Bogdan Gusiev | 2015-10-05 | 1 | -27/+19 |
| | |||||
* | raise ActiveModel::MissingAttributeError when trying to access a ↵ | Diego Carrion | 2015-06-16 | 1 | -1/+1 |
| | | | | | | | | relationship without the foreign key attribute fixes regression reported on #20253 ActiveRecord::Base#[] was not used cause of 8b95420 | ||||
* | Improve consistency of counter caches updating in memory | Sean Griffin | 2015-01-26 | 1 | -0/+3 |
| | | | | | | | | | | | | | | | | | When we made sure that the counter gets updated in memory, we only did it on the has many side. The has many side only does the update if the belongs to cannot. The belongs to side was updated to update the counter cache (if it is able). This means that we need to check if the belongs_to is able to update in memory on the has_many side. We also found an inconsistency where the reflection names were used to grab the association which should update the counter cache. Since reflection names are now strings, this means it was using a different instance than the one which would have the inverse instance set. Fixes #18689 [Sean Griffin & anthonynavarre] | ||||
* | Improve the performance of reading belongs_to associations | Sean Griffin | 2014-12-22 | 1 | -5/+6 |
| | | | | | | | | | | | | `ActiveRecord::Base#[]` has overhead that was introduced in 4.2. The `foo["id"]` working with PKs other than ID isn't really a case that we want to support publicly, but deprecating was painful enough that we avoid it. `_read_attribute` was introduced as the faster alternative for use internally. By using that, we can save a lot of overhead. We also save some overhead by reading the attribute one fewer times in `stale_state`. Fixes #18151 | ||||
* | add has_one? method and reuse instead of checking macro | eileencodes | 2014-06-09 | 1 | -1/+1 |
| | | | | | | Instead of checking for `macro == :has_one` throughout the codebase we can create a `has_one?` method to match the `belongs_to?`, `polymorphic?` and other methods. | ||||
* | Hide BelongsToAssociation#increment_counters and #decrement_counters | Jean Boussier | 2014-04-15 | 1 | -2/+2 |
| | |||||
* | Use inheritance chain instead of callbacks to increment counter caches after ↵ | Jean Boussier | 2014-04-14 | 1 | -4/+14 |
| | | | | create | ||||
* | 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! |