aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
Commit message (Collapse)AuthorAgeFilesLines
* Tiny documentation edits [ci skip]Robin Dupret2015-02-241-3/+1
|
* Require `belongs_to` by default.Josef Šimánek2015-02-211-1/+7
| | | | Deprecate `required` option in favor of `optional` for belongs_to.
* Merge pull request #16989 from Empact/reload-cache-clearRafael Mendonça França2015-02-201-9/+27
|\ | | | | | | Isolate access to @associations_cache and @aggregations_cache to the Associations and Aggregations modules, respectively.
| * Isolate access to @associations_cache and @aggregations cache to the ↵Ben Woosley2014-09-281-9/+27
| | | | | | | | | | | | | | | | Associations and Aggregations modules, respectively. This includes replacing the `association_cache` accessor with a more limited `association_cached?` accessor and making `clear_association_cache` and `clear_aggregation_cache` private.
* | Replace deprecated readonly option with scope blocks in docs and guideKonstantinos Rousis2015-02-181-2/+2
| |
* | Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-02-141-3/+3
|\ \
| * | Do not use the same name for two `:belongs_to`claudiob2015-02-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | A model cannot have two `:belongs_to` with the same exact name, so we are better off avoiding this code in our examples, which might mislead users in thinking it's admissible. [ci skip]
* | | [ci skip] corrects documentation for the default dependent behaviourAlex Handley2015-02-091-1/+1
| | | | | | | | | | | | | | | By default the foreign key will remain set with the parent id after destroy is fired.
* | | [ci skip] add note about has_one :through and :dependentpalkan2015-02-011-0/+4
|/ /
* | Document has_many :extend optionCaleb Thompson2015-01-081-0/+4
| | | | | | | | https://github.com/rails/rails/commit/5937bd02dee112646469848d7fe8a8bfcef5b4c1#commitcomment-9205786
* | Share foreign_key_present? implementation in _has_ associationsbrainopia2014-12-311-0/+1
| |
* | Add foreign_type option for polymorphic has_one and has_many.Ulisses Almeida + Kassio Borges2014-12-081-0/+12
| | | | | | | | | | | | | | To be possible to use a custom column name to save/read the polymorphic associated type in a has_many or has_one polymorphic association, now users can use the option :foreign_type to inform in what column the associated object type will be saved.
* | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
| |
* | Ensure HABTM relationships produce valid class names (Fixes #17119)Sammy Larbi2014-11-091-1/+1
| |
* | Raise an error for has_one associations which try to go :through a ↵Tu Hoang2014-10-151-0/+6
|/ | | | polymorphic association [#17263]
* Clarify the documentation of the primary_key option for associationsPeter Marsh2014-09-221-1/+1
| | | | | | | Previously the documentation stated that `primary_key` should be the name of a *method* that returns the primary key used for the association. This is incorrect. This changes the documentation to say that the value must be the name of a column.
* [ci skip] Added documentation for has_and_belongs_to_many extension parameterTom Kadwill2014-08-261-0/+15
|
* Fix a few typos [ci skip]Robin Dupret2014-08-241-1/+1
|
* [ci skip] Added documentation for has_many extension parameterTom Kadwill2014-08-241-0/+14
|
* [ci skip] Added documentation for has_and_belongs_to_many scope parameterTom Kadwill2014-08-221-0/+12
|
* Merge pull request #16204 from jonatack/patch-7Vijay Dev2014-08-211-12/+14
|\ | | | | Fix minor typos and improve grammar and code formatting
| * Grammar passJon Atack2014-08-191-12/+14
| | | | | | | | | | | | [ci skip] Add improvements from @eileencodes [skip ci]
* | [ci skip] Added documentation for has_one scope parameterTom Kadwill2014-08-211-0/+11
| |
* | [ci skip] Added documentation for has_many scope parameterTom Kadwill2014-08-201-0/+11
| |
* | Merge pull request #16475 from tomkadwill/has_many_scope_documentationZachary Scott2014-08-191-0/+11
|\ \ | | | | | | [ci skip] Added documentation for belongs_to scope parameter
| * | [ci skip] Added documentation for belongs_to scope parameterTom Kadwill2014-08-191-0/+11
| | |
* | | Use string for order argument, fixed from #16501 [ci skip]Zachary Scott2014-08-141-1/+1
| | |
* | | Merge pull request #16501 from tomkadwill/update_delete_to_new_styleZachary Scott2014-08-141-1/+1
|\ \ \ | | | | | | | | [ci skip] updated 'where' in association documention to new style syntax
| * | | [ci skip] updated 'where' in association documention to new style syntaxTom Kadwill2014-08-141-1/+1
| |/ /
* / / [ci skip] Updated where scope to conform to new styleTom Kadwill2014-08-131-1/+1
|/ /
* | [ci skip] Changed options to +options+ for rdocTom Kadwill2014-08-091-4/+4
| |
* | [ci skip] Changed 'first argument' to '+name+ argument'Tom Kadwill2014-08-081-4/+4
| |
* | Touch option description grammatical error fixed [ci skip]vadivelan2014-07-211-1/+1
|/
* [CI SKIP] Doc fix.Guo Xiang Tan2014-07-151-2/+2
|
* Begin refactoring ThroughReflectioneileencodes2014-07-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows us to decouple AssociationReflection and ThroughReflection making ThroughReflection it's own Reflection bucket in a way. The benefit of this is to be able to remove checks against the macro's symbol for exmaple `macro == :belongs_to`. Get all tests passing again Some of the methods that used to be inherited from MacroReflection through AssociationReflection were no longer getting passed through. They needed to be duplicated into the ThroughReflection. I will extract these out into a separate class. Refactor shared methods into strategy object Now that we've separated ThroughReflection and AssociationReflection we can combine shared methods into one class to avoid duplication. Break out class for each type of reflection This creates a class for each reflection type (has_many, has_one, belongs_to and habtm). We then can remove the need to set the macro symbol in each initialization. Tests were updated to reflect these changes because creation of these reflections is now different. Remove need for @collection instance var We now define `collection?` as `false` by default and set it to `true` in `has_and_belongs_to_many` and `has_many` reflections. This removes the need for the `@collection` instance variable. Raise exception on unknown macro types We shouldn't accept just any macro when creating reflections. An unrecongnized AssociationReflection raises an error. Tests in `reflection_test` were updated to reflect these new changes. `:has_and_belongs_to_many` macro tests were removed because we no longer internally return HABTM.
* Add a `required` option to singular associationsSean Griffin2014-07-041-0/+10
| | | | | | | | | | | | | | | | | | | | | | In addition to defining the association, a `required` association will also have its presence validated. Before: ```ruby belongs_to :account validates_presence_of :account ``` After: ```ruby belongs_to :account, required: true ``` This helps to draw a distinction between types of validations, since validations on associations are generally for data integrity purposes, and aren't usually set through form inputs.
* Use HasAndBelongsToMany instead of HABTMArthur Neves2014-06-091-1/+1
|
* Abstract away use of HABTM macroeileencodes2014-06-091-1/+1
| | | | | | | | | By having the `:has_and_belongs_to_many` macro in the `@collection` we are punishing `:has_many` associations because it has to allocate the array and check the macro. @collection is returned to `macro == :has_many` and a new reflection class `HABTMReflection` is created to handle this case instead.
* Refactoring .reflections public method.Arthur Neves2014-05-261-3/+4
| | | | | | Now the internal reflections will hold a reference to its public representation, so when the outside world calls `Account.reflection` we can build a list of public reflections.
* Use .to_s on _reflections lookupArthur Neves2014-05-241-1/+1
|
* Merge pull request #15210 from arthurnn/fix_hbtm_reflectionArthur Neves2014-05-241-2/+5
| | | | | | | | | Fix habtm reflection Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/counter_cache.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/reflection_test.rb
* Added force_reload to Auto-generated methods docdanielmbarlow2014-05-231-2/+3
| | | Should make it a little easier to find the information. Also added note to look below for the definition of the generated methods.
* docs, fix typo in docs added by ed56e596a04673. [ci skip]Yves Senn2014-05-101-2/+2
|
* deprecate, join, preload, eager load of instance dependent associations.Yves Senn2014-05-101-0/+4
| | | | | | | Closes #15024. These operations happen before instances are created. The current behavior is misleading and can result in broken behavior.
* set a constant for the "anonymous" habtm model fixes #15022Aaron Patterson2014-05-081-0/+5
| | | | | I wanted the middle model to be anonymous, but we have to give it a name for marshal support. :'(
* docs, restructure newly added part to `includes`. [ci skip]Yves Senn2014-05-031-6/+5
| | | | | | This is a follow up to #14139. /cc @carlosantoniodasilva
* cleanup, remove trailing whitespace. [ci skip]Yves Senn2014-04-291-1/+1
|
* Merge pull request #14139 from anilmaurya/masterYves Senn2014-04-281-0/+6
|\ | | | | [ci skip] updating active_record/associations to demonstrate where conflict with eager loading.
| * [ci skip] updating active_record/associations to demonstrate where conflict ↵anilmaurya2014-04-291-0/+6
| | | | | | | | with eager loading.
* | Fix custom join_table name on habtm reflectionsKassio Borges2014-04-251-1/+1
| | | | | | | | | | | | When used a custom join_table name on a habtm, rails was not saving it on Reflections. This causes a problem when rails loads fixtures, because it uses the reflections to set database with fixtures.