I have a rake task to seed an application with random data using the faker gem. However, we also have images (like logos) that we want uploaded in this rake task.
We already have Paperclip set up, but don't have a way to upload them programmatically in a rake task. Any ideas?
I didn't actually have to write a method for this. Much simpler.
In Model ->
In seed.db ->
Perhaps the previous answers meant to use the name of the attachment as defined in the model (rather than writing a method Model_name.attachment). Hope this is clear.
I do something like this in a rake task.
I hope this helps!
What do you mean by programmatically? You can set up a method that will take a file path along the lines of
#attachment
comes from our Paperclip declaration in our model. In this case, our model looks likeWe've done things similar to this when bootstrapping a project.