如何将Rails模型导出到JSON模式? [英] How can I export a rails model to json schema?
问题描述
我正在寻求优化我们为某些模型构建表单的方式,理想情况下,我想从json-schema生成表单.
I am looking to optimize how we build forms for some of our models and ideally I would like to build them from json-schema.
有没有可以让我将模型定义导出到json-schema的gem或类似的东西?
Is there a gem or the like which would allow me to export a model definition to json-schema?
奖金:带有验证.
奖金:在对关联关系进行建模时.
Bonus: While modelling association relationships.
推荐答案
格式: http://github.com /justinfrench/formtastic 具有一种从模型构建表单的机制.也许您可以基于他们的代码.
Formtastic: http://github.com/justinfrench/formtastic has a mechanism for building forms from the models. Maybe you could base your code on theirs.
检入lib/formtastic.rb第474行左右.
Check in lib/formtastic.rb line 474 or so.
用于形式的轨道广播: http://railscasts.com/episodes/184-formtastic -part-1
Railscast for formtastic: http://railscasts.com/episodes/184-formtastic-part-1
这篇关于如何将Rails模型导出到JSON模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!