Skip to content

Unable to pass options to serializer when using ActiveModelSerializers #141

@rbhitchcock

Description

@rbhitchcock

ActiveModelSerializer allows for options to be passed to the serializer from the controller. RocketPants does not seem to support this at this time. If it does, could you please point me to instructions on how to do it?

It seems like the fix for this would be to update this line (

) to pass the options variable to #serializable_hash.

SerializerWrapper = Struct.new(:serializer, :object) do

      def serializable_hash(options = {})
        instance = serializer.new(object, options)
        if instance.respond_to?(:serializable_hash)
          instance.serializable_hash
        else
          instance.as_json options
        end
      end

    end

I would be happy to make this change and submit a PR if that is the proper fix for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions