Ruby on Rails Thursday, February 23, 2017

On Thu, Feb 23, 2017 at 9:28 AM mike r <mike.reider@gmail.com> wrote:
hello all, Im developing a ruby script (ruby 1.8.7)

its a simple script to generate an email using an ERB

my ERB has this 

JIRA ticket:
[ <%= issue_key %> ] - <%= summary %> 


I was wondering if its possible to embed that hyperlink somehow the ERB. When I get the email from this script, it embeds everything as plain text, I cant find a way to embed a hyperlink into a string

similar to this, 

<a href="https://jira-server/etc"> [ ABC-123 ] </a>

If you want the link text to be the last bit of the issue_key, you can get that by using the built-in File.basename method, and make this your content:

<a href="<%= issue_key %>">[ <%= File.basename(issue_key) %> ]</a>

Note that this is an off-label use of File.basename, but it works since URL paths look just like file paths. I have no recollection of the libraries available in 1.8.7 which has been obsolete for years now, but File.basename was there.

Tamara

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHUC_t-3UETMdp%3DrvWvvz22%3DJGwS-x1UGSuuJjpD4OYAymqJ1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment