Skip to content

Instantly share code, notes, and snippets.

@ahmdrefat
Created October 21, 2012 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmdrefat/3926334 to your computer and use it in GitHub Desktop.
Save ahmdrefat/3926334 to your computer and use it in GitHub Desktop.
def get_educations
educations = Education.find_all_by_full_profile_id(current_user.full_profile.id)
if educations.empty?
client = get_client
educations = client.profile(:fields => [:educations]).educations.all
educations.each do |e|
new_educations = Education.create(
school_name: e.school_name,
field_of_study: e.field_of_study,
start_date: Date.parse("1/#{e.end_date.month ? p.end_date.month : 1}/#{e.end_date.year}"),
end_date: Date.parse("1/#{e.end_date.month ? p.end_date.month : 1}/#{e.end_date.year}"),
degree: e.degree,
activities: e.activities,
notes: e.notes,
full_profile_id: current_user.full_profile.id)
end
current_user.full_profile.educations
else
educations
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment