views:

97

answers:

2

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.

Is there a gem or the like which would allow me to export a model definition to json-schema?

Bonus: With validations.

Bonus: While modelling association relationships.

A: 

I dont know about a gem that does this, but you could either pull the SQL or Rails schema data and then parse it, even easier if you're working with thw rails schema, as you can parse it by running it in a Ruby DSL.

thomasfedb
Nod, it certainly seems doable, which is why I was hoping someone had already done it ;)
unomi
A: 

Formtastic: http://github.com/justinfrench/formtastic has a mechanism for building forms from the models. Maybe you could base your code on theirs.

Check in lib/formtastic.rb line 474 or so.

Railscast for formtastic: http://railscasts.com/episodes/184-formtastic-part-1

nkassis
This seems as good as it gets for the moment.. Thanks for the answer.
unomi