Skip to content

Instantly share code, notes, and snippets.

@the-teacher
Created August 28, 2013 06:15
Show Gist options
  • Save the-teacher/6362652 to your computer and use it in GitHub Desktop.
Save the-teacher/6362652 to your computer and use it in GitHub Desktop.
CSV_FIELDS = %w[
title
landing_type
point_nom_from
iata_from
point_nom_to
iata_to
slug_direct
slug_reverse
title_to
description_to
header_to
text_to
title_from
description_from
header_from
text_from
]
landing_hash = ... # JSON like params
land_params = CSV_FIELDS.inject({}){|res, item| res.merge(item => landing_hash[item])}
landing = Landing.where(title: landing_hash['title']).first_or_create!(land_params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment