How do I add an image from my file system to a model with Paperclip in Rails?

api, paperclip, ruby, ruby-on-rails, rubygems

Solution

Yeah, shouldn't be a problem.

movie = Movie.first
movie.image = File.open("...")
movie.save!

Problem

I'm building an app for reviewing movies. I've cached a lot of movie data from an API. Essentially I have a movie model which has an `:image` attribute for Paperclip. What I've done is cache the remote image for each movie from the API onto my file system using a rake task. What I would like to do is the following: - For every movie I retrieve from the API with an image, set it's `:image` attribute to be the same image just stored on my file system for that particular movie. Is something like this possible with Paperclip? Or do I need to look into something else? With my current code, I can get reference to each image object but would Paperclip allow me to set the value of my model's :image attribute to the raw image object?

Original source