Created
November 1, 2009 11:24
-
-
Save dmitry/223480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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