Ruby on Rails Advanced JSON Serialization

前端 未结 7 926
闹比i
闹比i 2020-12-13 02:53

I\'m looking to render an index of all articles along with a full article via JSON in my rails app, but I\'m having a little trouble figuring out how to do it.

Here

7条回答
  •  -上瘾入骨i
    2020-12-13 03:26

    You should be able to nest the :include, :except, etc. like so:

    :except => {:item => [ :created_at, :updated_at, :draft, :id, :publish ]}...
    

    If that doesn't work, make it an object (e.g. an OpenStruct) instead of a hash.

    -- Markus

提交回复
热议问题