# Ruport - how to wrap \<a href=" "\> tags around text inside a ruport table

**URL:** <https://www.ruby-forum.com/t/ruport-how-to-wrap-a-href-tags-around-text-inside-a-ruport-table/157576>\
**Category:** Rails\
**Created:** [January 13, 2009, 10:29am UTC](https://www.ruby-forum.com/t/ruport-how-to-wrap-a-href-tags-around-text-inside-a-ruport-table/157576 "2009-01-13T10:29:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevej](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce7236/32.png) [@stevej](https://www.ruby-forum.com/u/stevej)\
**Post date:** [January 13, 2009, 10:29am UTC](https://www.ruby-forum.com/t/ruport-how-to-wrap-a-href-tags-around-text-inside-a-ruport-table/157576/1 "2009-01-13T10:29:02Z")

</div>

Anyone know how to embed a hyperlink in a ruport table? The url is in  
mysql. I’m using,after much head-banging, report\_table\_by\_sql to build  
a ruport table, which of course, also now contains the url text. I  
want to diplay each url as a hyperlink in the browser. I’m lazy an  
would like to use a ruby/rails/ruport function of some sort to parse  
this url and rewrite it as hyperlink (derivce text  
from url) as part of ruport.

Here’s an example:

This controller code generates a table:

#note : @low = 70 and @high = 100 thanks to params from a form…  
#note “link” refers to WAN circuits and not hyperlinks…

@links = Link.report\_table\_by\_sql [ "SELECT headend, out\_90th\_util,  
bandwidth, hyperlink  
FROM (SELECT \* FROM (SELECT \* FROM links ORDER BY link\_key  
DESC, out\_90th\_util DESC) t  
GROUP BY link\_key)t2  
WHERE out\_90th\_util \> ? AND out\_90th\_util \< ? ", @low,  
@high ]

Here is the corresponding view code that generates simple table in a  
browser:

### Table Using Ruport
\<%= @links.to\_html %\>

Here is a sample from the browser:

out\_90th\_util hyperlink bandwidth headend  
72  
[http://www.imadethisup.com/service/generate.cgi?target=%2Fgeograpyisfun%2Farouter99%2Fatm1\_ima1;view=Octets;ranges=m%3Ay](http://www.imadethisup.com/service/generate.cgi?target=%2Fgeograpyisfun%2Farouter99%2Fatm1_ima1;view=Octets;ranges=m%3Ay)  
3000000 arouter99

I need to subsitute something like this inside the report for the  
hyperlink:  
[  
arouter99\_atm\_ima1](http://www.imadethisup.com/service/generate.cgi?target=%2Fgeograpyisfun%2Farouter99%2Fatm1_ima1;view=Octets;ranges=m%3Ay)

I have not yet tinkered with ruport or rails enough to have much of  
clue. I’m hoping to get this working so I don’t revert back to perl.  
I must admit perl is looking pretty attractive at this point ;-)… I  
could try to wrap the http:// in tags inside mysql. But I would like  
to know if it can be done in ruport (if I don’t have control of the  
database table).

Thanks to anyone who bothered to read this far!
