Forum: Ruby on Rails link_to + image_tag

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.
Lost W. (Guest)
on 2008-10-17 10:42
i want to integrated link_to with image_tag

before i did link_to with image_tag like this

<%=link_to image_tag(image.filename
,:size=>'110x85'),{:action=>'thumb_crop',:controller=>'light',:id=>image.id},:class=>'lightview',:id=>image.id,:rel=>'iframe',:title=>image.filename+'/Crop/'.camelize+'fullscreen
:true'%>
but now
<%=image_tag ("/trx/images/ob.gif",:alt=>'mob',:title=>'mob')%>
<%=link_to
"Pass",{},:title=>'Mobile',:target=>'_blank',:href=>'http://www.goeoz.com.html?id=8006'
%>


now i want to display the text from link_to tag also


how to do pls reply
mahmoud said (Guest)
on 2008-10-17 11:17
(Received via mailing list)
I don't think i really get it...

do u mean u want to have both the image and the text included in the
link???

if it is so, simply concatenate those as following

<%= link_to  image_tag(image.filename,:size=>'110x85') + "Pass" ,
{:action=>'thumb_crop', :controller=>'light',:id=>image.id} %>
keep in mind that image_tag()  and even link_to()  returns strings in
the
end. and available for string operations

hope it helped


On Fri, Oct 17, 2008 at 8:42 AM, Lost W. <
removed_email_address@domain.invalid> wrote:

> but now
> how to do pls reply
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--
Mahmoud Said
Software Developer
blog.modsaid.com
www.eSpace.com.eg
+20-16-1223857
Xavier N. (Guest)
on 2008-10-17 11:25
(Received via mailing list)
On Fri, Oct 17, 2008 at 8:42 AM, Lost W.
<removed_email_address@domain.invalid> wrote:
> <%=link_to
> "Pass",{},:title=>'Mobile',:target=>'_blank',:href=>'http://www.goeoz.com.html?id=8006'
> %>
>
>
> now i want to display the text from link_to tag also

I don't know whether I follow you, the following may not help but let's
try.

The first argument of link_to is an arbitrary HTML fragment. You can
put there whatever you want.

The helper image_tag just returns a string containing HTML: "<img ...
/>", and that is what link_to receives in the first example. Just a
vanilla Ruby string. You can build on that one to pass whatever you
want to link_to.
This topic is locked and can not be replied to.