contentful / contentful_model

A lightweight wrapper around the Contentful api gem, to make it behave more like ActiveRecord
MIT License
44 stars 42 forks source link

`#raw` output on rich text fields contains model objects #142

Open dpikt opened 4 years ago

dpikt commented 4 years ago

Not sure if this is a bug or expected behavior- feel free to close if it's the latter.

I've got a model that has a rich text field with an embedded entry. When I call #raw on an instance of that model, the output contains the entry ruby object:

$ MyModel.raw

{
 "sys"=>{...},
 "fields"=> {
   "richTextField"=>
    {
      "data"=>{},
      "content"=>
      [{"data"=>{}, "content"=>[{"data"=>{}, "marks"=>[], "value"=>"", "nodeType"=>"text"}], "nodeType"=>"paragraph"},
       ...
       # Right here
       {"data"=>{"target"=><RelatedFile[relatedFiles] id=‘1JZpjo5NYPjYlvIZiIM8w5’>}, "content"=>[], "nodeType"=>"embedded-entry-block"},
      ],
     "nodeType"=>"document"
    }
  }
}

Should this just be the JSON of the API response instead?

asknacho commented 3 years ago

Still happening today, should we switch to Contentful::Client for this?

dlitvakb commented 3 years ago

This is expected behaviour.

Cheers

On Mon, Mar 22, 2021 at 5:11 PM Ignacio Morales @.***> wrote:

Still happening today, should we switch to Contentful::Client for this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/contentful/contentful_model/issues/142#issuecomment-804193936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH4EAT2YV4NZV4LO7TK6VTTE5T2XANCNFSM4MCQIHSQ .

-- David Litvak Bruno Solution Architect, Customer Experience - Solution Services Team

https://ctfl.io/3kAf9ak

@.*** +491629770622 Twitter @dlitvakb https://twitter.com/dlitvakb GitHub @dlitvakb https://github.com/dlitvakb LinkedIn in/dlitvakb/ https://www.linkedin.com/in/dlitvakb/

Contentful GmbH Ritterstraße 12-14 10969 Berlin, Germany https://goo.gl/maps/9qViWH2BwXB2

www.contentful.com

Privacy Policy https://www.contentful.com/legal/de/privacy/

Registration Court: Berlin-Charlottenburg HRB 155607 B

Managing Directors: Steve Sloan, Paolo Negri, Dr. Markus Harder