Skip to content

Instantly share code, notes, and snippets.

@andySF
Created September 4, 2012 20:20
Show Gist options
  • Save andySF/3626010 to your computer and use it in GitHub Desktop.
Save andySF/3626010 to your computer and use it in GitHub Desktop.
ruby installed programs
Program.transaction do
Program.update_all({:Installed=>FALSE}, {:machine_id=>params[:machine_id]})
params[:programs][:program].each do |t|
if(Program.exists?(:DisplayName=>t[:DisplayName], :Version=>t[:Version], :machine_id=>t[:machine_id]))
Program.where(:DisplayName=>t[:DisplayName], :Version=>t[:Version], :machine_id=>t[:machine_id]).update_all :Installed=>TRUE
else
Program.create(t)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment