Reputation: 1093
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?
Upvotes: 0
Views: 9886
Reputation: 597
<%= link_to "#{@data[:item_name]}", @data[:link] %>
If you need a hyperlink where you need the name of item along with link, you can do something similar to this.
<%= link_to "Task", Task_Link %>
Upvotes: 0
Reputation: 8408
Why don't you use the helper method?
<% @jobs.each do |job| %>
<%= link_to job.url, job.url %>
<% end %>
Upvotes: 1
Reputation: 728
I think the simplest solution would be to use the helper method link_to in the following way:
<% @jobs.each do |job| %>
<%= link_to job.url, job.url %>
<% end %>
The link_to helper is great for forming hyperlinks. All you need to supply is the URL and the anchor text. See the Ruby on Rails documentation for link_to
Upvotes: 0
Reputation: 7099
Like @Felix said, use the link_to helper
<% @somevar = job.url %>
<%= link_to "Anchor text", @somevar %>
Upvotes: 0