| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Fix minor typos and improve grammar and code formatting
|
| |
| |
| |
| |
| |
| | |
[ci skip]
Add improvements from @eileencodes [skip ci]
|
| | |
|
| | |
|
|\ \
| | |
| | | |
[ci skip] Added documentation for belongs_to scope parameter
|
| | | |
|
| | | |
|
|\ \ \
| | | |
| | | | |
[ci skip] updated 'where' in association documention to new style syntax
|
| |/ / |
|
|/ / |
|
| | |
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
| |
Should make it a little easier to find the information. Also added note to look below for the definition of the generated methods.
|
| |
|
|
|
|
|
|
|
| |
Closes #15024.
These operations happen before instances are created.
The current behavior is misleading and can result in broken behavior.
|
|
|
|
|
| |
I wanted the middle model to be anonymous, but we have to give it a name
for marshal support. :'(
|
|
|
|
|
|
| |
This is a follow up to #14139.
/cc @carlosantoniodasilva
|
| |
|
|\
| |
| | |
[ci skip] updating active_record/associations to demonstrate where conflict with eager loading.
|
| |
| |
| |
| | |
with eager loading.
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| | |
The new method relies on AR::Associations::Association knowing about both reflection and a model class.
AR::Base#association now raises a descriptive error when trying to access non-existent associations. Previously it would blow up with a confusing NoMethodError: undefined method `association_class' for nil:NilClass.
|
| |
| |
| |
| | |
Fixes #14383.
|
| | |
|
|\ \
| |/
|/| |
[ci skip] Move association class method notes
|
| |
| |
| |
| | |
Make explanation of association class methods clearer by moving notes to beginning of each example section.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
This is a follow up to #13926.
/cc @fxn
|
| | |
|
|/
|
|
|
|
|
|
| |
previous one is deleted even if the new one
doesn't get persisted to database.
Fixes #13197 . [ci skip]
|
| |
|
| |
|
| |
|
| |
|