The code:
user = ... #pretend it has a value :)
instances = Array.new
Product.all.each do |product|
productInstance = ProductInstance.new
productInstance.user = user
productInstance.product = product
instances.push(productInstance)
end
Product and ProductInstance are both Rails models. Is a for-each loop on Product.all going to be slow? Just wondering if there is a better way of doing this…
Somthing like this should work.
or even
For Mass assignment restriction you can try something like