From what you have tried it looks like you are very close. What if you try rendering it as a partial?
<% @devices.each do |device| %>
<%= render partial: 'form', locals: { device: device } %>
<% end %>
Another difference here is the scope of the device
param on the second line.