Search code examples
ruby-on-railsrubyapiactive-model-serializers

Can't add variable to ActiveModelSerializers::SerializableResource with Rails API


Using Rails 5.0.0

From example code, the usage of ActiveModelSerializers is:

ActiveModelSerializers::SerializableResource.new(resources, each_serializer: self)

How to add another instance_option such as tag: true?


Solution

  • Adding another key, value as args to the end should work

     ActiveModelSerializers::SerializableResource.new(resources, each_serializer: self, tag: true)