PaperClip: Attach files through script/console

I’m wondering is it possible to attach a file through script/console?

Worked this out for myself in a round about way, I used rest_client and
made a post locally, if anyone knows of a “neater” way I’d like to know

John O’gara wrote:

I’m wondering is it possible to attach a file through script/console?

On 21 ene, 19:53, John O’gara [email protected] wrote:

I’m wondering is it possible to attach a file through script/console?

image = Image.new(:storage => File.open(’/path/to/my/image.png’, rb))

Where:

Image is your model
storage is your paperclip definition of has_attachment.

HTH,

Thanks Luis, thats much neater.
Luis L. wrote:

image = Image.new(:storage => File.open(’/path/to/my/image.png’, rb))

Where:

Image is your model
storage is your paperclip definition of has_attachment.

HTH,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs