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