Search code examples
ruby-on-railsrubyjsonruby-on-rails-pluginsjsonschema

How can I export a rails model to 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.

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.


Solution

  • 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