What I am really trying to do is use the file_column plugin for the file
uplaod/storage (to a non-application directory), but serve up the images
on my own (without the mage_tag url_for_file_column technique)
In the java world, I would simply do something like this:
<img src="myImageServlet?id=1">
and myImageServlet would simply return the appropriate mime headers and
data that represented the image.
I am lost in the ruby/rails world.
My images are being stored in a NON application folder (I do not want
users to be able to access them directly...I want the retrieval of the
images to be controlled by an action.
I have an action in one of my controllers that looks something like
this:
def serve_user_image
@user = session[:user]
image_file = File.new(@user.image_filename, "rb")
send_data image_file, :filename => @user.image_filename, :type =>
"image/jpeg", :disposition => "inline"
end
And inside my view, something like this:
<%= image_tag url_for(:action => "serve_user_image" ) %>
However, aside from it not working, I get really weird things in my logs
like
"Parameters: {"action"=>"serve_user_image.png",
"controller"=>"main"}
Now, there is no reference to a png in my code...(the filename is a
.jpg), so I assume I am doing something dreadfuly wrong.
Any pointers would be appreciated
--
Posted via http://www.ruby-forum.com/.