Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Only call set_owner_attributes for has_one association if target exists. | Dieter Komendera | 2011-07-04 | 1 | -1/+1 |
| | |||||
* | When you add a record to a polymorphic has_one, you should be able to access ↵ | Jon Leighton | 2011-06-08 | 1 | -1/+1 |
| | | | | the owner from the associated record | ||||
* | Don't remove the target if it has already been destroyed | Andrew White | 2011-05-11 | 1 | -1/+1 |
| | |||||
* | Remove `#among?` from Active Support | Prem Sichanugrist | 2011-04-13 | 1 | -1/+1 |
| | | | | | | 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?`. | ||||
* | Change Object#either? to Object#among? -- thanks to @jamesarosen for the ↵ | David Heinemeier Hansson | 2011-04-12 | 1 | -1/+1 |
| | | | | suggestion! | ||||
* | Using Object#in? and Object#either? in various places | Prem Sichanugrist | 2011-04-11 | 1 | -1/+3 |
| | | | | 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?. | ||||
* | Move the code which builds a scope for through associations into a generic ↵ | Jon Leighton | 2011-03-10 | 1 | -6/+0 |
| | | | | AssociationScope class which is capable of building a scope for any association. | ||||
* | Use proper objects to do the work to build the associations (adding methods, ↵ | Jon Leighton | 2011-02-21 | 1 | -4/+15 |
| | | | | callbacks etc) rather than calling a whole bunch of methods with rather long names. | ||||
* | Delegate Association#options to the reflection, and replace ↵ | Jon Leighton | 2011-02-21 | 1 | -2/+2 |
| | | | | '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 | -13/+13 |
| | | | | accessing the instance variables | ||||
* | Let's be less blasé about method visibility on association proxies | Jon Leighton | 2011-01-30 | 1 | -1/+4 |
| | |||||
* | 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 | -2/+1 |
| | |||||
* | Abstract common code from BelongsToAssociation and HasOneAssociation into ↵ | Jon Leighton | 2011-01-16 | 1 | -18/+5 |
| | | | | SingularAssociation | ||||
* | Support for create_association! for has_one associations | Jon Leighton | 2011-01-11 | 1 | -1/+4 |
| | |||||
* | When assigning a has_one, if anything fails, the assignment should be rolled ↵ | Jon Leighton | 2011-01-11 | 1 | -19/+23 |
| | | | | back entirely | ||||
* | When assigning a has_one, if the new record fails to save, raise an error | Jon Leighton | 2011-01-11 | 1 | -3/+3 |
| | |||||
* | When assigning a has_one, if the existing record fails to be removed from ↵ | Jon Leighton | 2011-01-11 | 1 | -5/+11 |
| | | | | the association, raise an error | ||||
* | has_one should always remove the old record (properly), even if not saving ↵ | Jon Leighton | 2011-01-11 | 1 | -1/+1 |
| | | | | the new record, so we don't get the database into a pickle | ||||
* | Refactor HasOneAssociation#replace | Jon Leighton | 2011-01-07 | 1 | -26/+22 |
| | |||||
* | Don't not remove double negatives | Jon Leighton | 2011-01-07 | 1 | -4/+4 |
| | |||||
* | Clean up create, create! and build in HasOneAssociation | Jon Leighton | 2011-01-07 | 1 | -14/+8 |
| | |||||
* | merge_with_conditions is not necessary because the conditions will already ↵ | Jon Leighton | 2011-01-07 | 1 | -9/+0 |
| | | | | be in the scope_for_create hash in the scope | ||||
* | Not really worth having the HasAssociation module for just a single method | Jon Leighton | 2011-01-07 | 1 | -2/+0 |
| | |||||
* | Construct an actual ActiveRecord::Relation object for the association scope, ↵ | Jon Leighton | 2011-01-07 | 1 | -11/+3 |
| | | | | 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. | ||||
* | Remove undocumented feature from has_one where you could pass false as the ↵ | Jon Leighton | 2011-01-03 | 1 | -20/+8 |
| | | | | | | | | | | | | second parameter to build_assoc or create_assoc, and the existing associated object would be untouched (the foreign key would not be nullified, and it would not be deleted). If you want behaviour similar to this you can do the following things: * Use :dependent => :nullify (or don't specify :dependent) if you want to prevent the existing associated object from being deleted * Use has_many if you actually want multiple associated objects * Explicitly set the foreign key if, for some reason, you really need to have multiple objects associated with the same has_one. E.g. previous = obj.assoc obj.create_assoc previous.update_attributes(:obj_id => obj.id) | ||||
* | Create the association scope directly rather than going through with_scope | Jon Leighton | 2011-01-03 | 1 | -2/+2 |
| | |||||
* | Use the association directly in other places too | Jon Leighton | 2011-01-03 | 1 | -11/+9 |
| | |||||
* | Allow assignment on has_one :through where the owner is a new record [#5137 ↵ | Jon Leighton | 2011-01-03 | 1 | -3/+1 |
| | | | | | | | | | | 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 | -3/+3 |
| | | | | options key which it relates to is :foreign_key | ||||
* | And owner_quoted_id can go too | Jon Leighton | 2010-12-31 | 1 | -9/+0 |
| | |||||
* | Refactor we_can_set_the_inverse_on_this? to use a less bizarre name amongst ↵ | Jon Leighton | 2010-12-26 | 1 | -8/+3 |
| | | | | other things | ||||
* | Add a HasAssociation module for common code for has_* associations | Jon Leighton | 2010-12-26 | 1 | -0/+2 |
| | |||||
* | Remove AssociationProxy#dependent? - it's badly named and only used in one place | Jon Leighton | 2010-12-26 | 1 | -1/+1 |
| | |||||
* | Associations: DRY up the code which is generating conditions, and make it ↵ | Jon Leighton | 2010-12-26 | 1 | -14/+3 |
| | | | | all use arel rather than SQL strings | ||||
* | using arel to compile sql statements | Aaron Patterson | 2010-12-25 | 1 | -1/+2 |
| | |||||
* | Partialy revert f1c13b0dd7b22b5f6289ca1a09f1d7a8c7c8584b | José Valim | 2010-11-28 | 1 | -1/+1 |
| | |||||
* | use persisted? instead of new_record? wherever possible | David Chelimsky | 2010-11-09 | 1 | -6/+6 |
| | | | | | | | | | | | - 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 | -23/+16 |
| | | | | 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 | -7/+7 |
| | |||||
* | Adds title to activerecord/lib/active_record/associations/* | Rizwan Reza | 2010-06-16 | 1 | -0/+1 |
| | |||||
* | Add more tests for the various ways we can assign objects to associations. ↵ | Murray Steele | 2009-12-28 | 1 | -2/+1 |
| | | | | | | | | [#3513 state:resolved] Get rid of a duplicate set_inverse_instance call if you use new_record(true) (e.g. you want to replace the existing instance). Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com> | ||||
* | Set inverse for #replace on a has_one association. [#3513 state:resolved] | George Ogata | 2009-12-28 | 1 | -0/+1 |
| | | | | Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com> | ||||
* | Make has_one with :conditions hash scope build or creation of the associated ↵ | Luciano G Panaro | 2009-09-28 | 1 | -0/+9 |
| | | | | | | | object with those conditions Signed-off-by: Michael Koziarski <michael@koziarski.com> [#3088 state:committed] | ||||
* | HasOneAssociation inherits AssociationProxy since it shares nothing with ↵ | Emilio Tagua | 2009-06-12 | 1 | -5/+5 |
| | | | | | | | | BelongsToAssociation. [#2796 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net> | ||||
* | Revert "Fixed bug with polymorphic has_one :as pointing to an STI record" | Jeremy Kemper | 2009-05-11 | 1 | -1/+1 |
| | | | | | | [#2594 state:open] This reverts commit 99c103be1165da9c8299bc0977188ecf167e06a5. | ||||
* | Providing support for :inverse_of as an option to associations. | Murray Steele | 2009-05-04 | 1 | -1/+10 |
| | | | | | | | | | | | | | | | | | | | | | | 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> | ||||
* | Fixed bug with polymorphic has_one :as pointing to an STI record | Ruy Asan | 2009-05-01 | 1 | -1/+1 |
| | | | | | | [#2594 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net> |