notonthehighstreet/serialization_extensions — pull request #1 by guiman (2014-11-26 15:55:45+00:00)
Title: Fix bug when serialization_options get persisted for an object

So let me explain a bit what we found:

```
class Enquiry
has_many messages, class: EnquiryMessage
end

class EnquiryMessage
belongs_to :enquiry
end
```

On Rails4, when we build a message for a particular enquiry, and then try to:
```
@message.serialize_with(include: :enquiry)
@message.to_json
```

It will start to recursively call itself, make the application lock. This is because in rails 4, the object inside the enquiry.messages.first is the exact same object as `@message`, and so it will try to include again the `enquiry` when serializing.

Rails 3 does not have this problem because `enquiry.messages.first.object_id != @message.object_id`.