i'm trying overwrite default to_json method in model. there numerous jbuilder partials models, named model does, in snake case. so:
jbuilder.encode |json| json.partial! "charts/#{self.class.name.demodulize.underscore}" end but actually, got node in json, named "partial!" , string value.
how render jbuilder partial inside rails model?
as disclaimer, dirty hack. it's better avoid such code.
builder = jbuildertemplate.new(applicationcontroller.new.view_context) builder.partial!("foo/bar") activesupport::json.decode(builder.target!)
Comments
Post a Comment