Displaying inline image from params

I’d like to display an image from the data submitted from a file field
before it’s written to the database, but I’m having a hard time
figuring it out. If I put the send_data function into crop, the image
displays, but without the layout, but the way it’s set up below, the
data isn’t being passed to the temporary_photo display.

Is there a better way to do this? Help!

The controller

def crop
@photo = Photo.new( params[:photo] )
end

def temporary_photo
@photo = Photo.new( params[:photo] )
send_data(@photo.attachment_data,
:filename => @photo.filename,
:type => @photo.content_type,
:disposition => “inline”)
end

crop.rhtml

<%= image_tag url_for( :action => :temporary_photo ) %>

Jack W Jennings schrieb:

def crop

crop.rhtml

<%= image_tag url_for( :action => :temporary_photo ) %>

Try this:

<img src="<%= url_for(:controller => “your_conroller”,
:acion => “temporary_photo2,
:id => @photo_id %>” />

Works here.


Jochen K.
railswerk.de, gissmoh.de, figgfrosch.de, ror-ror.de

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