title: Create a object from another object in rails
body: <p>I want to create some records in my mysql database using some existing records. I am using rails 4.2</p>
  
  <p>This is the relevat code in my controller:</p>
  
  <pre><code>linkconfig_id = 17
  new_config = Linkconfigdetail.where(:linkconfig_id =&gt; user_params[:linkconfig_id])
  
  new_config.each do |config|
    config[:linkconfig_id] = linkconfig_id
    config[:id] = nil
    config[:created_at] = nil
    config[:updated_at] = nil
  end
  
  Linkconfigdetail.create(new_config)
  </code></pre>
  
  <p>The new_config variable contains a few datasets of the Linkconfigdetail-model. I want to slightly change them and then save them as new, but I get the error message:</p>
  
  <pre><code>ArgumentError (When assigning attributes, you must pass a hash as an argument.): 
  </code></pre>
  
  <p>and the line of the create-method. </p>
  
  <p>I already checked. The new_config-array is not nil. It is looking like this, before the create (using inspect):</p>
  
  <pre><code>#&lt;ActiveRecord::Relation [#&lt;Linkconfigdetail id: nil, linkconfig_id: 17, link_id: 1, location: 0, created_at: nil, updated_at: nil&gt;, #&lt;Linkconfigdetail id: nil, linkconfig_id: 17, link_id: 18, location: 1, created_at: nil, updated_at: nil&gt;, #&lt;Linkconfigdetail id: ...
  </code></pre>
  
  <p>I appreciate every hint, or any other solution to this problem in general. I can't imagine, that this is so difficult. I already had a lot of problems to even change the dataset. Many methods like delete didn't work, but I finally  couldn't find a way to work around this issue.</p>