Using Paperclip within seeds.rb
paperclip, ruby, ruby-on-rails, seed
Solution
Rather than setting the asset columns directly, try leveraging paperclip and setting it as ruby `File` object.
Image.create({
:id => 52,
:asset => File.new(Rails.root.join('path', 'to', 'somefile.jpg')),
:product_id => 52
})
Problem
Let's says I have the following entry in my `seeds.rb` file : ``` Image.create(:id => 52, :asset_file_name => "somefile.jpg", :asset_file_size => 101668, :asset_content_type => "image/jpeg", :product_id => 52) ``` If I seed it, it tries to process the image specified, I get this error : ``` No such file or directory - {file path} etc... ``` My images are backed up, so I don't really need to create them; but I need the record though. I can't comment the paperclip directive in my model; then it works; but I guess there might be another solution. Is there another pattern to follow in order to accomplish it ? Or a turnaround to tell paperclip not to process the image ?