Search code examples
ruby-on-railsjsonweb-servicesactiverecordmodels

JSON view of an ActiveRecord model


I want to build a RESTful WebService that's using JSON for externalizing resources. The problem that I'm currently facing is how to construct a stripped-off version of my models so that I could offer clients a simplified interface without unneeded information. The best aproach I could come up with is defining a method for every model that I'm interested in that builds this simplified facade object. Is there a better design pattern for this ?


Solution

  • You can try rabl or jbuilder.