json.id @<%= resource.underscore %>.id.to_s json.extract! @<%= resource.underscore %><%= fields_as_params %> <% fields.each do |name, type| %><% if type == "has_many" %>json.<%= name %> @<%= resource.underscore %>.<%= name %>, :id, :name <% end %><% if type == "belongs_to" %> json.partial! 'faalis/relations/belongs_to', object: @<%= resource.underscore %>.<%= name %>, :name => :<%= name %>, :fields => [:id, :name] <% end %><% end %>