Skip to content

Instantly share code, notes, and snippets.

@chopmo chopmo/gist:2874877
Created Jun 5, 2012

Embed
What would you like to do?
irb(main):002:0> p = Page.new
irb(main):005:0> p.image = File.open("/Users/jtj/sample_assets/a.JPG")
irb(main):008:0> p.save
# Delay while versions are uploaded
irb(main):009:0> p.image.url
=> https://s3.amazonaws.com/dk.workingbits.dts/uploads/page/image/17/a.JPG
irb(main):011:0> p.image.url(:thumbnail)
=> "https://s3.amazonaws.com/dk.workingbits.dts/uploads/page/image/17/thumbnail_a.JPG"
@sunny0425

This comment has been minimized.

Copy link

commented Mar 13, 2013

For Line 2-3, I think maybe you should change to in order to auto close the file:

File.open("/Users/jtj/sample_assets/a.JPG") do |f|
p.image = f
p.save
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.