I have this example code which raises a "Duplicate Expection". Instead, I want just to skip if a duplicate exists.
(1..10).each do |page|
group.products << [{id: 1, title: "Example A"}, {id: 2, title: "Example B"}]
group.save
end
The product array is static just for this example, what matter is that it has ID's, so products exist in the database.
The problem is when I assign a product that I have already assigned in the past which raise a "Not Unique exception". In this scenario, I would just skip the association. How is that possible?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)