Before introducing strong params
it was working fine.
So, on creating a new object using new
and passing attributes, id
was being set as nil
.
But now, when I am creating a new object, obj2 from existing object, obj1's attributes,
id
(a primary key) of obj1 is also being copied to obj2.
Like,
obj2 = Post.new obj1.attributes
So, problem arises when I try to save it,
obj2.save
with ActiveRecord::RecordNotUnique
error. As both object have the same id.
I have several models with the same use case, so if I use dup
or except
, I'll have to add the same in each case.