I have an ActiveRecord object (x) with some records in it.
First, I want to create an empty recordset (y). Something like :
y = x.class.new EDIT: -or- y = ActiveRecord::Relation.new
Second, I want to copy (duplicate) a record from x to y. Something like :
y << x.first.dup
How can I do that ? (Is it possible ?)
I have an error on the first line, saying that an argument is missing. I'm able to make new String with this method, but not with ActiveRecord objects.
# x.class : ActiveRecord::Relation::ActiveRecord_Relation_Analysis
x = Analysis.where(category: 6)
# In a helper ...
# The x object is not always an Analysis. So I must use its class
y = x.class.new
Error on the last line :
ArgumentError: wrong number of arguments (0 for 1+)
from .. /activerecord-4.0.1/lib/active_record/relation/delegation.rb:76:in `new'