Ruby on Rails Advanced JSON Serialization

前端 未结 7 930
闹比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条回答
  •  隐瞒了意图╮
    2020-12-13 03:14

    to_json has a :method option that includes the result of any method you name, you could define a method on that model that returns the additional data you want in your JSON.

提交回复
热议问题