@@ -21,6 +21,27 @@ functionality as you had with `AMS 0.8`. Then, you can continue to develop in yo
21
21
new serializers that don't use these backwards compatible versions and slowly migrate
22
22
existing serializers to the ` 0.10 ` versions as needed.
23
23
24
+ ### Basic list ` 0.10 ` breaking changes
25
+ - Passing a serializer to ` render json: ` is no longer supported
26
+ - Ex. ` render json: CustomerSerializer.new(customer) `
27
+ - Passing a nil resource to serializer now fails
28
+ - Ex. ` CustomerSerializer.new(nil) `
29
+ - Attribute methods are no longer accessible from other serializer methods
30
+ - Ex.
31
+ ``` ruby
32
+ class MySerializer
33
+ attributes :foo , :bar
34
+
35
+ def foo
36
+ bar + 1
37
+ end
38
+ end
39
+ ```
40
+ - ` root` option to collection serializer behaves differently
41
+ - Ex . ` ActiveModel::ArraySerializer.new(resources, root: "resources")`
42
+ - No default serializer when serializer doesn' t exist
43
+ - `@options` changed to `instance_options`
44
+
24
45
## Steps to migrate
25
46
26
47
### 1. Upgrade the `active_model_serializer` gem in you `Gemfile`
@@ -46,10 +67,10 @@ module ActiveModel
46
67
# Since attributes could be read from the `object` via `method_missing`,
47
68
# the `try` method did not behave as before. This patches `try` with the
48
69
# original implementation plus the addition of
49
- # ` || object.respond_to?(a.first)` to check if the object responded to
70
+ # ` || object.respond_to?(a.first, true )` to check if the object responded to
50
71
# the given method.
51
72
def try(*a, &b)
52
- if a.empty? || respond_to?(a.first) || object.respond_to?(a.first)
73
+ if a.empty? || respond_to?(a.first, true ) || object.respond_to?(a.first, true )
53
74
try!(*a, &b)
54
75
end
55
76
end
0 commit comments