Skip to content

Instantly share code, notes, and snippets.

@remogatto
Created February 22, 2011 15:46
Show Gist options
  • Save remogatto/838861 to your computer and use it in GitHub Desktop.
Save remogatto/838861 to your computer and use it in GitHub Desktop.
def create
['gift', 'encoding', 'epd'].each do |param|
eval <<EOC
if active_#{param}
puts "#{param} CREATE"
delete_item = #{param.capitalize}.find_by_task_id(task_id)
delete_item.delete unless delete_item.nil?
new_item = #{param.capitalize}.new(#{param})
new_task.#{param} = new_item
new_task.save
else
puts "DISATTIVA #{param}!"
new_task.active_#{param} = false
new_task.#{param}.delete
new_task.save
end
EOC
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment