JBuilder和to_json的区别是什么?

4

Jbuilder使用as_json还是to_json进行渲染?

我正在尝试使用别名覆盖as_json和to_json,类似于以下内容:

  module BSON
    class ObjectId

      def as_json(*args)
        to_s
      end

      alias :to_json :as_json

    end
  end

然后使用 JBuilder 渲染返回对象。但是,它似乎没有使用 to_json 或 as_json 进行渲染。

1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接