Created
March 11, 2010 00:09
-
-
Save ilake/328625 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You'll also need a controller to send the photo data when the image is requested by a web browser. This can be done all in one action with respond_to and an extra mime type. In environment.rb, declare the types of the images that you will be serving. | |
Mime::Type.register "image/jpeg", :jpg | |
Mime::Type.register "image/png", :png | |
def show | |
@photo = Photo.find params[:id] | |
respond_to do |format| | |
format.html | |
format.jpg do | |
send_data @photo.data, { | |
:disposition => "inline", | |
:type => "image/jpeg" | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment