Skip to content

Instantly share code, notes, and snippets.

@dmitry

dmitry/gist:223480

Created Nov 1, 2009
Embed
What would you like to do?
self.include_root_in_json = false
def export
json = to_json(:include => [:door_profile, :door_lift, :door_hinge, :door_handle, :door_glass], :except => [:created_at, :updated_at, :door_id, :id, :order_id, :user_id])
attributes = ActiveSupport::JSON.decode(json)
%w[door_profile door_lift door_hinge door_handle door_glass].each do |v|
if attributes[v]
attributes["#{v.to_s}_attributes"] = attributes[v]
attributes.delete(v)
end
end
ActiveSupport::JSON.encode(attributes)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment