Skip to content
This repository was archived by the owner on Jul 11, 2020. It is now read-only.
This repository was archived by the owner on Jul 11, 2020. It is now read-only.

read_only attributes not being added to metadata when not using default serializer #11

Description

@marktran

I'm seeing an issue where read_only attributes aren't in the read_only metadata if e.g. I have an EventsController that uses a serializer named BasicEventSerializer (or anything that's not the default EventSerializer).

Looks like it's because RenderJsonMeta::MetadataReadOnly only looks for the default serializer:

serializer = model.try(:active_model_serializer)

class EventsController < APIController
  handles :show

  def show
    render(
      json: self.record = model.find(params[primary_key]),
      serializer: BasicEventSerializer
    )
  end
end
class BasicEventSerializer < ActiveModel::Serializer
  embed :ids

  attributes :id
  read_only :created_at
end
{
  "event": {
    "id": 24522,
    "created_at": "2014-11-24T16:02:08.383Z"
  },
  "meta": {
    "event": {
      "read_only": [],
      "nested_resources": []
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions