Skip to content

Instantly share code, notes, and snippets.

@Vaguery
Created September 21, 2010 13:43
Show Gist options
  • Select an option

  • Save Vaguery/589699 to your computer and use it in GitHub Desktop.

Select an option

Save Vaguery/589699 to your computer and use it in GitHub Desktop.
answers.each do |answer|
execute <<-query
INSERT INTO scores (name, value, answer_id) VALUES (
'#{answer.name}',
#{answer.score.value},
#{answer.answer_id})
query
end
guts = answers.inject("") do |query,answer|
query + "('#{answer.name}',#{answer.score.value},#{answer.answer_id})" + ","
end
execute <<-query
INSERT INTO scores (name, value, answer_id) VALUES (#{guts.chop})
query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment