How to give link to image in .erb file

650 views
Skip to first unread message

amritpal pathak

unread,
Feb 5, 2011, 12:41:53 AM2/5/11
to rubyonra...@googlegroups.com
i am new to ruby.I want to add one image to my webpage.Please tell me how to give a link to image from .erb file??
Thanks

Colin Law

unread,
Feb 5, 2011, 4:00:11 AM2/5/11
to rubyonra...@googlegroups.com
On 5 February 2011 05:41, amritpal pathak <amritpa...@gmail.com> wrote:
> i am new to ruby.I want to add one image to my webpage.Please tell me how to
> give a link to image from .erb file??

Put the image in the application public folder and use image_tag.
See http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html

Colin

vishal singh

unread,
Feb 5, 2011, 7:49:03 AM2/5/11
to rubyonra...@googlegroups.com
hi .......for this u install the imagemagic rick



Colin Law

unread,
Feb 5, 2011, 8:33:57 AM2/5/11
to rubyonra...@googlegroups.com
On 5 February 2011 12:49, vishal singh <vishal....@gmail.com> wrote:
> hi .......for this u install the imagemagic rick

That is not necessary if all you are trying to do is display an image
on a web page.

Colin

loganathan sellappa

unread,
Feb 5, 2011, 11:22:54 AM2/5/11
to rubyonra...@googlegroups.com
just place ur image in public>images,then simply incl in view fileude it

loganathan sellappa

unread,
Feb 5, 2011, 11:23:41 AM2/5/11
to rubyonra...@googlegroups.com
just place ur image in public>images,then simply include it in view file

frankblizzard

unread,
Feb 5, 2011, 11:48:16 AM2/5/11
to Ruby on Rails: Talk
you could do something like:

<%= link_to image_tag("name of image in public/images", :border =>
0 ), target-object , :title => "title text" %>

*where target-objet is the object you want to link to, e.g. post or
product or whatever object
Reply all
Reply to author
Forward
0 new messages