aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_many_through_association.rb
Commit message (Collapse)AuthorAgeFilesLines
...
| * Always update counter caches in memory when adding recordsSean Griffin2014-06-161-1/+0
| | | | | | | | | | | | | | | | | | | | | | Before, calling `size` would only work if it skipped the cache, and would return a different result from the cache, but only if: - The association was previously loaded - Or you called size previously - But only if the size was 0 when you called it This ensures that the counter is appropriately updated in memory.
* | Merge pull request #15772 from nbudin/sti_through_bugRafael Mendonça França2014-06-191-1/+3
|\ \ | |/ |/| | | Don't include inheritance column in the through_scope_attributes
| * Don't include inheritance column in the through_scope_attributesNat Budin2014-06-171-1/+1
|/
* Merge pull request #15701 from zzak/issue_15496Rafael Mendonça França2014-06-131-1/+5
|\ | | | | Open extension point for defining options in build_through_record
| * Open extension point for defining options in build_through_recordZachary Scott2014-06-131-1/+5
| | | | | | | | This fixes #15496
* | Through associations should set both parent ids on join modelsSean Griffin2014-06-131-1/+5
|/ | | | | | | | | | | | | member = Member.new(club: Club.new) member.save! Before: member.current_membership.club_id # => nil After: member.current_membership.club_id # => club's id
* reuse available collection? check instead of macroeileencodes2014-06-091-3/+3
| | | | | | | Reflection has an available method that is used to check if the reflection is a collection. Any :has_many macro is considered a collection and `collection?` should be used instead of `macro == :has_many`.
* add has_one? method and reuse instead of checking macroeileencodes2014-06-091-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.
* Do not try to set the foreign_key again on has_many throughRafael Mendonça França2014-06-091-1/+1
| | | | | | | Integration tests are inside protected_attributes test suite. Fixes #15496 Fixes rails/protected_attributes#35
* reuse available belongs_to? methodeileencodes2014-06-031-1/+1
| | | | | | | | | | Reflection has a `belongs_to?` method. Instead of checking for `macro == :belongs_to` throughout the source reuse existing method. I also bumped `foreign_key_present?` method onto on line because the `belongs_to?` makes it shorter than other longer lines in the same class.
* rename delete_all_records to delete_or_nullify_all_recordseileencodes2014-05-131-6/+2
| | | | | | | Rename delete_all_records because this name better describes what the method is doing. We can then remove :all from the hm:t version and pull out the unoptimized call to load_target in delete_records and pass it directly.
* begin refactoring delete_records methodeileencodes2014-05-131-0/+4
| | | | | | | | | | | | | | Refactor by creating two methods delete_all_records and delete_records to be called by delete_all and delete (or destroy) respectively. This reduces the number of conditionals required to handle _how_ records get deleted. The new delete_count method handles how scope is applied to which delete action. A delete_all_records method also has to be called in has_many_through association because of how the methods are chained. This will be refactored later on.
* Fixed HABTM's CollectionAssociation sizeFred Wu2014-05-081-1/+1
| | | | | HABTM should fall back to using the normal CollectionAssociation's size calculation if the collection is not cached or loaded. This addresses both #14913 and #14914 for master.
* Follow-up to #14990 [ci skip]Jon Atack2014-05-071-10/+9
| | | | | | | | Rewrite to avoid 'we'/'you', add missing period, and keep lines at 80 chars. Cheers :) Improve readability with help from @senny [ci skip]
* Fixed grammarFred Wu2014-05-061-1/+1
|
* use cache queries for hm:t associationsAaron Patterson2014-04-151-1/+1
|
* again, read_attribute is public, so just call itAaron Patterson2014-04-131-1/+1
|
* Merge pull request #12829 from iantropov/issue_insert_via_hmt_scope_3548Rafael Mendonça França2014-04-101-1/+5
|\ | | | | | | | | | | | | Fix insertion of records for hmt association with scope Conflicts: activerecord/CHANGELOG.md
| * Fix insertion of records for hmt association with scope, fix #3548Ivan Antropov2013-11-171-1/+5
| |
* | let `insert_record` actuall save the object.Aaron Patterson2014-02-251-2/+1
|/ | | | | | | | | | `before_add` callbacks are fired before the record is saved on `has_and_belongs_to_many` assocations *and* on `has_many :through` associations. Before this change, `before_add` callbacks would be fired before the record was saved on `has_and_belongs_to_many` associations, but *not* on `has_many :through` associations. Fixes #14144
* Prevent the counter cache from being decremented twicedm1try2013-11-111-1/+1
| | | | | when destroying a record on a has_many :through association. :destroy method has own counter_cache callbacks.
* fix deleting join models with no pkAaron Patterson2013-09-111-1/+15
|
* Adding a bang to method name of raise_on_type_mismatch.wangjohn2013-03-211-1/+1
|
* Reverting 16f6f25 (Change behaviour with empty array in where clause)Guillermo Iguaran2013-02-081-1/+1
|
* Change behaviour with empty array in where clauserobertomiranda2013-02-081-1/+1
|
* target_reflection_has_associated_record? refactoringAngelo Capilleri2013-01-081-5/+1
|
* Fix for has_many_through counter_cache bugMatthew Robertson2012-12-141-0/+5
| | | | | | This commit fixes reported issue #7630 in which counter caches were not being updated properly when replacing has_many_through relationships
* Merge pull request #7251 from rails/integrate-strong_parametersDavid Heinemeier Hansson2012-09-181-2/+2
|\ | | | | Integrate strong_parameters in Rails 4
| * Remove mass_assignment_options from ActiveRecordGuillermo Iguaran2012-09-161-2/+2
| |
* | Fix collection= on hm:t join models when unsavedErnie Miller2012-09-171-0/+14
|/ | | | | | If assigning to a has_many :through collection against an unsaved object using the collection=[<array_of_items>] syntax, the join models were not properly created, previously.
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* s/scoped/scope/Jon Leighton2012-08-011-2/+2
|
* Deprecate Relation#all.Jon Leighton2012-07-271-1/+1
| | | | | | It has been moved to active_record_deprecated_finders. Use #to_a instead.
* no longer need #delete_all_on_destroyJon Leighton2012-05-181-4/+0
|
* Perf: Don't load the association for #delete_all.Jon Leighton2012-05-181-1/+6
| | | | Bug #6289
* Not need to pass join attributes to association buildRafael Mendonça França2012-03-071-1/+3
|
* Fix #3672 again (dependent: delete_all perf)Jon Leighton2011-12-141-0/+4
|
* Memoize through associationJon Leighton2011-11-031-8/+11
|
* Remove all revelant through records.Jon Leighton2011-11-031-9/+9
| | | | | | | | | If a record is removed from a has_many :through, all of the join records relating to that record should also be removed from the through association's target. (Previously the records were removed in the database, but only one was removed from the in-memory target array.)
* Fix adding multiple instances of the same record to a has_many :through.Jon Leighton2011-11-031-21/+43
| | | | Fixes #3425.
* added an alias for new to build to the AR collection proxy, this corrects an ↵Josh Kalderimis2011-06-011-2/+0
| | | | issue where the collection proxies were not consistent
* Only save the record once when calling create! on a collection association. ↵Jon Leighton2011-05-311-2/+9
| | | | Fixes #1360.
* singular and collection relations in AR can now specify mass-assignment ↵Josh Kalderimis2011-05-011-2/+2
| | | | security options (:as and :without_protection) in build, create and create! methods.
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-62/+97
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb 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_association.rb activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/lib/active_record/associations/has_one_association.rb activerecord/lib/active_record/associations/has_one_through_association.rb activerecord/lib/active_record/associations/through_association_scope.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/associations/has_many_through_associations_test.rb activerecord/test/cases/associations/has_one_through_associations_test.rb activerecord/test/cases/reflection_test.rb activerecord/test/cases/relations_test.rb activerecord/test/fixtures/memberships.yml activerecord/test/models/categorization.rb activerecord/test/models/category.rb activerecord/test/models/member.rb activerecord/test/models/reference.rb activerecord/test/models/tagging.rb
| * Delegate through_reflection and source_reflection to reflectionJon Leighton2011-02-211-10/+10
| |
| * Associations - where possible, call attributes methods rather than directly ↵Jon Leighton2011-02-211-13/+13
| | | | | | | | accessing the instance variables
| * Split AssociationProxy into an Association class (and subclasses) which ↵Jon Leighton2011-02-181-11/+9
| | | | | | | | manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
| * Allow building and then later saving has_many :through records, such that ↵Jon Leighton2011-02-181-4/+46
| | | | | | | | the join record is automatically saved too. This requires the :inverse_of option to be set on the source association in the join model. See the CHANGELOG for details. [#4329 state:resolved]
| * Get rid of AssociationCollection#save_recordJon Leighton2011-02-141-4/+13
| |
| * just return the record from insert_record, use truthiness for comparisonsAaron Patterson2011-02-071-2/+2
| |