diff --git a/docs/howto/upgrade_from_0_8_to_0_10.md b/docs/howto/upgrade_from_0_8_to_0_10.md index 0c76fcb6..619713c1 100644 --- a/docs/howto/upgrade_from_0_8_to_0_10.md +++ b/docs/howto/upgrade_from_0_8_to_0_10.md @@ -21,6 +21,27 @@ functionality as you had with `AMS 0.8`. Then, you can continue to develop in yo new serializers that don't use these backwards compatible versions and slowly migrate existing serializers to the `0.10` versions as needed. +### Basic list `0.10` breaking changes +- Passing a serializer to `render json:` is no longer supported + - Ex. `render json: CustomerSerializer.new(customer)` +- Passing a nil resource to serializer now fails + - Ex. `CustomerSerializer.new(nil)` +- Attribute methods are no longer accessible from other serializer methods + - Ex. + ```ruby + class MySerializer + attributes :foo, :bar + + def foo + bar + 1 + end + end + ``` + - `root` option to collection serializer behaves differently + - Ex. `ActiveModel::ArraySerializer.new(resources, root: "resources")` +- No default serializer when serializer doesn't exist +- `@options` changed to `instance_options` + ## Steps to migrate ### 1. Upgrade the `active_model_serializer` gem in you `Gemfile` @@ -46,10 +67,10 @@ module ActiveModel # Since attributes could be read from the `object` via `method_missing`, # the `try` method did not behave as before. This patches `try` with the # original implementation plus the addition of - # ` || object.respond_to?(a.first)` to check if the object responded to + # ` || object.respond_to?(a.first, true)` to check if the object responded to # the given method. def try(*a, &b) - if a.empty? || respond_to?(a.first) || object.respond_to?(a.first) + if a.empty? || respond_to?(a.first, true) || object.respond_to?(a.first, true) try!(*a, &b) end end