I’m trying to display an image (chart) that lives outside the public
directory in RAILS_ROOT/private.
The chart contains confidential information and so can’t live in /public
or any sub-directories of /public.
The chart needs to be displayed from a partial. The first display of
the page containing the partial is an html render. Subsequently, the
user can select a different chart causing an ajax call which replaces
the content of the image-containing dom element in the partial with a
new chart image.
Any thoughts / pointers are much appreciated!
Best regards,
Bill
bill walton wrote:
I’m trying to display an image (chart) that lives outside the public
directory in RAILS_ROOT/private.
You probably looking for send_file:
http://railsapi.com/doc/rails-v2.3.5/classes/ActionController/Streaming.html#M001587
Hi Rob,
On Mon, May 3, 2010 at 2:11 PM, Robert W. [email protected]
wrote:
bill walton wrote:
I’m trying to display an image (chart) that lives outside the public
directory in RAILS_ROOT/private.
You probably looking for send_file:
Yeah. I was trying to use send_data and it wasn’t working. Not sure
why,
but send_file does. I got it working but gmail doesn’t send my own
posts to
me so couldn’t reply that I’d solved it. Thanks much for replying. I
appreciate it.
Best regards,
Bill
You could have PrivateImagesController with show
method
and you will get your images through /private_images/image_name.png
in show
method
(check permissions)
send_file
“#{RAILS_ROOT}/private_images_folder/#{params[:image_name]}”
send_file is really slow and will work only when there’s not a lot of
users
requesting files
In Nginx you could use x-send-file option or something, which makes
send_file work much better. I didn’t try that though.