JBuilder as_json to_json
Does Jbuilder use as_json or to_json for rendering?
I am trying to override as_json and to_json with an alias like the one below:
module BSON
class ObjectId
def as_json(*args)
to_s
end
alias :to_json :as_json
end
end
Then use JBuilder to render the returned object. However, it acts as if it uses neither to_json nor as_json for rendering.
+3
source to share