I'd like to update several single table cell in my view with ajax. Is there a chance to run the uptime partial several times during the loop? Currently the loop iterates over all given records but the partial runs once.
def CheckUptimes
require 'net/ssh'
@username = "updater"
@password = "üqwlp+ß$2"
@cmd = "uptime"
@items = Item.all.where("(category = 'Ubuntu 14 LTS')")
@items.each do |ci|
@hostname = ci.name
begin
ssh = Net::SSH.start(@hostname, @username, :password => @password)
@uptime = ssh.exec!(@cmd)
ssh.close
@uptime = @uptime.strip
ci.update_attributes(:uptime => @uptime)
respond_to do |format|
format.html
format.js { render :partial => "uptime", :locals => { :id => ci.id, :uptime => @uptime } }
end
rescue
puts "Unable to connect to #{@hostname} using #{@username}/#{@password}"
end
end
end