aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_many_through_association.rb
Commit message (Collapse)AuthorAgeFilesLines
...
| * Refactor the implementations of AssociatioCollection#delete and #destroy to ↵Jon Leighton2011-02-071-1/+1
| | | | | | | | be more consistent with each other, and to stop passing blocks around, thus making the execution easier to follow.
| * Correctly update counter caches on deletion for has_many :through [#2824 ↵Jon Leighton2011-02-071-5/+24
| | | | | | | | state:resolved]. Also fixed a bunch of other counter cache bugs in the process, as once I fixed this one others started appearing like nobody's business.
| * Support the :dependent option on has_many :through associations. For ↵Jon Leighton2011-02-071-9/+8
| | | | | | | | historical and practical reasons, :delete_all is the default deletion strategy employed by association.delete(*records), despite the fact that the default strategy is :nullify for regular has_many. Also, this only works at all if the source reflection is a belongs_to. For other situations, you should directly modify the through association.
| * Make record.association.destroy(*records) on habtm and hm:t only delete ↵Jon Leighton2011-02-071-10/+11
| | | | | | | | records in the join table. This is to make the destroy method more consistent across the different types of associations. For more details see the CHANGELOG entry.
| * Let's be less blasé about method visibility on association proxiesJon Leighton2011-01-301-7/+10
| |
| * Let AssociationCollection#find use #scoped to do its finding. Note that I am ↵Jon Leighton2011-01-031-5/+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.
| * Allow assignment on has_one :through where the owner is a new record [#5137 ↵Jon Leighton2011-01-031-1/+0
| | | | | | | | | | | | | | | | | | | | 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 Leighton2010-12-311-1/+1
| | | | | | | | options key which it relates to is :foreign_key
| * I N C E P T I O N: flatten_deeper works around a bug in Ruby 1.8.2.Aaron Patterson2010-12-271-1/+1
| |
| * Refactor we_can_set_the_inverse_on_this? to use a less bizarre name amongst ↵Jon Leighton2010-12-261-1/+1
| | | | | | | | other things
| * Add a HasAssociation module for common code for has_* associationsJon Leighton2010-12-261-2/+1
| |
| * Use conditionals and implicit returns rather than explicit returns and ↵Jon Leighton2010-12-261-3/+7
| | | | | | | | postfix ifs (it's easier to read)
| * Remove has_cached_counter? and cached_counter_attribute_name from ↵Jon Leighton2010-12-261-8/+0
| | | | | | | | HasManyThroughAssociation, as the exact same methods are inherited from HasManyAssociation
| * Use the through association proxy for operations on the through record, so ↵Jon Leighton2010-12-261-2/+2
| | | | | | | | that those operations are automatically scoped and therefore construct_join_attributes does not need to use construct_owner_attributes.
| * If a has_many goes :through a belongs_to, and the foreign key of the ↵Jon Leighton2010-12-231-0/+1
| | | | | | | | belongs_to changes, then the has_many should be considered stale.
| * Delete create, create! and create_record from HasManyThroughAssociation in ↵Jon Leighton2010-12-201-18/+0
| | | | | | | | exchange for more generic versions in AssociationCollection
| * Specify insert_record with NotImplementedError in AssociationCollection, to ↵Jon Leighton2010-12-201-5/+1
| | | | | | | | indicate that subclasses should implement it. Also add save_record to reduce duplication.
| * Respect the default_scope on a join model when reading a through associationJon Leighton2010-12-161-1/+1
| |
| * just copy the joins to the listAaron Patterson2010-12-161-1/+1
| |
* | Merge branch 'master' into nested_has_many_throughJon Leighton2010-12-121-2/+2
|\| | | | | | | | | | | | | | | 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
| * Partialy revert f1c13b0dd7b22b5f6289ca1a09f1d7a8c7c8584bJosé Valim2010-11-281-2/+2
| |
* | Merge branch 'master' into nested_has_many_throughJon Leighton2010-11-171-3/+2
|\| | | | | | | | | | | Conflicts: activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/test/cases/associations/has_many_through_associations_test.rb
| * Remove unused varSantiago Pastorino2010-11-141-1/+1
| |
| * Fix bug where size of through association is not correct after adding a ↵Jason Cheow2010-11-141-1/+0
| | | | | | | | | | | | | | | | has_many association (occurs only before main object has been reloaded). [#5968 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
| * use persisted? instead of new_record? wherever possibleDavid Chelimsky2010-11-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | - 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 Leighton2010-10-301-15/+1
| | | | | | | | 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.
* | Fix naughty trailing whitespaceJon Leighton2010-10-311-2/+2
| |
* | Remove obsolete require to active_record/associations/nested_has_many_throughJon Leighton2010-10-191-1/+0
| |
* | Refactoring: replace the mix of variables like @finder_sql, @counter_sql, ↵Jon Leighton2010-10-171-15/+1
| | | | | | | | 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.
* | Make sure nested through associations are read onlyJon Leighton2010-10-151-0/+10
| |
* | Integrate nested support into ThroughAssociationScope, using my concept of ↵Jon Leighton2010-10-021-1/+0
| | | | | | | | generating a 'chain' of reflections to be joined. It seems to work at the moment, all existing tests are passing. There may be further complications as we add more test cases for nested associations, though.
* | Started implementing nested :through associations by using the existing ↵Jon Leighton2010-10-011-1/+1
| | | | | | | | structure of ThroughAssociationScope rather than layering a module over the top
* | Initial nested_has_many_through support [#1152]Bodaniel Jeanes2010-09-261-0/+2
|/
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-3/+3
| | | | 's/[ \t]*$//' -i {} \;)
* ensuring that description does not exceed 100 columnsNeeraj Singh2010-08-021-3/+4
|
* Adds title to activerecord/lib/active_record/associations/*Rizwan Reza2010-06-161-0/+1
|
* adds missing requires for Object#blank? and Object#present?Xavier Noria2010-03-281-0/+1
|
* save(false) is gone, use save(:validate => false) instead.José Valim2010-01-171-1/+1
|
* Make scopes use relations under the hoodPratik Naik2010-01-161-2/+0
|
* Merge commit 'rails/master'Emilio Tagua2009-08-101-19/+16
|\
| * Remove unnecessary scoping for creating hm:t join recordPratik Naik2009-08-101-3/+4
| |
| * Remove unnecessary scoping and validation checks from hm:t#createPratik Naik2009-08-101-1/+1
| |
| * Unify hm:t#create and create! implementationPratik Naik2009-08-101-17/+13
| |
* | Merge commit 'rails/master'Emilio Tagua2009-08-101-2/+6
|\| | | | | | | | | | | | | Conflicts: activerecord/lib/active_record/calculations.rb activerecord/lib/active_record/connection_adapters/mysql_adapter.rb activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
| * has_many :through create should not raise validation errorsrailsbob2009-08-091-1/+5
| | | | | | | | | | | | [#2934 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
| * Ensure hm:t#find does not assign nil to :include [#1845 state:resolved]railsbob2009-08-091-1/+1
| | | | | | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* | Merge commit 'rails/master'Emilio Tagua2009-08-101-0/+4
|\| | | | | | | | | Conflicts: activerecord/lib/active_record/migration.rb
| * Ensure hm:t#create/create! throws ActiveRecord::RecordNotSaved when the ↵Pratik Naik2009-08-081-0/+4
| | | | | | | | owner is new
* | Merge commit 'rails/master'Emilio Tagua2009-06-301-9/+1
|\|
| * Revert "Revert "Generate proper :counter_sql from :finder_sql when there is ↵Pratik Naik2009-07-011-9/+1
| | | | | | | | | | | | | | | | | | a newline character immediately following 'SELECT' [#2118 state:resolved]"" This reverts commit 80f1f863cd0f9cba89079511282de5710a2e1832. The feature doesn't work on Postgres, so don't test it on Postgres. Also, Postgres compatibility is irrelevant to the ticket/patch in question.