Forum: Ruby on Rails How downloading image in rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E5d4db2f53bec777e0d25acbeb3f706e?d=identicon&s=25 Veera Sundaravel (veeraa2003)
on 2007-05-07 16:20
Hi everybody,

I want to display a link for downloading image from database.

def image
  @image = Classified.find(params[:id])
  send_data @image.picture, :filename => "photo.jpg",
 :type => @image.content_type, :disposition => "attachment"

end


<%= image_tag (url_for({:action => 'image',
 :id => @classified.id})) -%>


But its still display the image only not displaying the link to
download.


I use both :disposition as "inline" and "attachment". But I cant get the
link to download the image file. How is it possible. Please advice me.


Regards,
Veeraa
21f7ed21f11a809050594c82eab11d67?d=identicon&s=25 Robert Walker (Guest)
on 2007-05-07 16:37
(Received via mailing list)
Take a look at send_data method.  Use this method within a controller
action to send the data for your image to the client browser.  You
will then connect your action to a regular hyperlink within your view
in the normal way.

On May 7, 10:20 am, Veera Sundaravel <rails-mailing-l...@andreas-
E5d4db2f53bec777e0d25acbeb3f706e?d=identicon&s=25 Veera Sundaravel (veeraa2003)
on 2007-05-08 07:19
Robert Walker wrote:
> Take a look at send_data method.  Use this method within a controller
> action to send the data for your image to the client browser.  You
> will then connect your action to a regular hyperlink within your view
> in the normal way.
>
> On May 7, 10:20 am, Veera Sundaravel <rails-mailing-l...@andreas-

HI Robert,

Thanks for your kind reply. Thanks a lot.


By veeraa.....
This topic is locked and can not be replied to.