steve98177
2009-Jan-13 07:00 UTC
ruport - how to wrap <a href=" "> tags around text inside a ruport table
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 (<a href=" ...url">derivce
text
from url</a>) 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:
<h3>Table Using Ruport</h3>
<%= @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
3000000 arouter99
I need to subsitute something like this inside the report for the
hyperlink:
<a href="
http://www.imadethisup.com/service/generate.cgi?target=%2Fgeograpyisfun%2Farouter99%2Fatm1_ima1;view=Octets;ranges=m%3Ay">
arouter99_atm_ima1</a>
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!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---