Skip to content

Commit e966d07

Browse files
committed
PR comments
- Add list of breaking changes - Add `true` param to `responds_to?` calls in overriden `try`
1 parent 3ecc3ed commit e966d07

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

docs/howto/upgrade_from_0_8_to_0_10.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ functionality as you had with `AMS 0.8`. Then, you can continue to develop in yo
2121
new serializers that don't use these backwards compatible versions and slowly migrate
2222
existing serializers to the `0.10` versions as needed.
2323

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+
2445
## Steps to migrate
2546
2647
### 1. Upgrade the `active_model_serializer` gem in you `Gemfile`
@@ -46,10 +67,10 @@ module ActiveModel
4667
# Since attributes could be read from the `object` via `method_missing`,
4768
# the `try` method did not behave as before. This patches `try` with the
4869
# 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
5071
# the given method.
5172
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)
5374
try!(*a, &b)
5475
end
5576
end

0 commit comments

Comments
 (0)