我的 Post 模型中有这个“as_json”方法:
def as_json(options={})
super(options.merge(:include => { :comments => { :include => [:user] }, :hashtags => {}, :user => {}, :group => {} }))
end
我想像这样设置一个限制属性:comments
:
def as_json(options={})
super(options.merge(:include => { :comments => { :include => [:user], :limit => 10 }, :hashtags => {}, :user => {}, :group => {} }))
end
但它不起作用。
我应该如何进行?