Search code examples
ruby-on-railshyperlinkhref

a Href links in ruby


This is pretty straightforward.

I want to make a href link in html point to a site urls thats determined by a ruby variable. So heres what I have:

<% @jobs.each do |job| %>
<% @tempJobUrl = job.url%>
<a href=<%=job.url%></a><%= job.url %>

job is an object which has the variable of url. The url is pretty standard format http://www.google.com and thats what shows up in the table. However when I press the link, it takes me to the page with

%3C/a

on the end.

Any ideas where this is coming from?


Solution

  • Why don't you use the helper method?

    <% @jobs.each do |job| %>
      <%= link_to job.url, job.url %>
    <% end %>