You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -545,6 +545,9 @@ The relationship methods (`relationship`, `has_one`, and `has_many`) support the
545
545
`to_one` relationships support the additional option:
546
546
*`foreign_key_on` - defaults to `:self`. To indicate that the foreign key is on the related resource specify `:related`.
547
547
548
+
`to_many` relationships support the additional option:
549
+
*`reflect` - defaults to `true`. To indicate that updates to the relationship are performed on the related resource, if relationship reflection is turned on. See [Configuration] (#configuration)
550
+
548
551
Examples:
549
552
550
553
```ruby
@@ -1133,6 +1136,13 @@ Callbacks can be defined for the following `JSONAPI::Resource` events:
1133
1136
- `:remove_to_one_link`
1134
1137
- `:replace_fields`
1135
1138
1139
+
###### Relationship Reflection
1140
+
1141
+
By default updates to relationships only invoke callbacks on the primary
1142
+
Resource. By setting the `use_relationship_reflection` [Configuration] (#configuration) option
1143
+
updates to `has_many` relationships will occur on the related resource, triggering
1144
+
callbacks on both resources.
1145
+
1136
1146
##### `JSONAPI::Processor` Callbacks
1137
1147
1138
1148
Callbacks can also be defined for `JSONAPI::Processor` events:
@@ -1944,13 +1954,18 @@ JSONAPI.configure do |config|
1944
1954
# NOTE: always_include_to_many_linkage_data is not currently implemented
1945
1955
config.always_include_to_one_linkage_data =false
1946
1956
1957
+
# Relationship reflection invokes the related resource when updates
1958
+
# are made to a has_many relationship. By default relationship_reflection
1959
+
# is turned off because it imposes a small performance penalty.
1960
+
config.use_relationship_reflection =false
1961
+
1947
1962
# Allows transactions for creating and updating records
1948
1963
# Set this to false if your backend does not support transactions (e.g. Mongodb)
1949
-
self.allow_transactions =true
1964
+
config.allow_transactions =true
1950
1965
1951
1966
# Formatter Caching
1952
1967
# Set to false to disable caching of string operations on keys and links.
0 commit comments