ruby on rails - Can I convert model with one of its associations to YAML format? -
i want print activerecord model in yaml format debugging purposes.
currently invoke model.to_yaml
. doesn't return model's associations
how can convert model 1 of associations yaml format?
you can convert json first. default activerecord as_json
method allows include assocations. there, it's straightforward convert yaml. example:
menu.as_json(include: :dishes).to_yaml
Comments
Post a Comment