将RABL的输出存储为ActiveRecord属性

时间:2012-11-28 12:22:05

标签: ruby-on-rails rabl

我需要在使用RABL模板渲染后将JSON对象存储为ActiveRecord属性。我怎样才能做到这一点?

一个简单的例子是

MyModel.my_data = <output from the RABL template>

1 个答案:

答案 0 :(得分:1)

查看https://github.com/nesquena/rabl#rendering-templates-directly

Rabl::Renderer.json(@model, 'model/show')

应该可以做到这一点。