Attach document using carrierwave from console
<p>I have a document 'example.docx' located in public folder of my app.</p>

<p>I want <strong>to create a subject record from the console that has that document attached</strong> using carrierwave gem like this:</p>

<pre><code>Subject.create(group_id: 3, type: 1, attachment: __________)
</code></pre>

<p>subject.rb:</p>

<pre><code>mount_uploader :attachment, FileUploader
</code></pre>

<p>I tried to do as it is written in documentation:</p>

<pre><code>subject = Subject.new
File.open("public/example.docx") do |f|
  subject.attachment = f
end
subject.save!
</code></pre>

<p>But <code>subject.attachment.url</code> results in <code>NoMethodError: undefined method `url' for "#&lt;File.........&gt;":String</code></p>