Reputation: 295
I'm generating a hypertext link to an individual article via ERB with the link_to
helper method, yet when the link is displayed in the view it renders as an HREF clickable link, but it's not clickable (arrow doesn't even turn to a pointer)
I've tried manipulating the link_to helper and specifically the article_path(:id)
, but the href path in the dev tools is rendering the correct path with the code below.
I've also double checked my routes, as well as permitted params.
<% @articles.reverse.each do |article| %>
<div class="article_card">
<div>
<%= markdown(article.text[0..405]<<"...") %>
</div>
</div>
# This is the link that isn't clickable
<%= link_to 'Show full article', article_path(article) %>
<% end%>
and this is what it renders in dev tools:
<a href="/articles/20">Show full article</a>
I expect the rendered href to be clickable and GET the articles/:id
Upvotes: 0
Views: 254
Reputation: 15848
inspect the element using the browser's dev tools, maybe you have some invisible element above the A tag, maybe you have some javascript messing things up, the generated html looks fine, I don't think it's a rails issue
EDIT: check J.R. Bob Dodds answer below
Upvotes: 1
Reputation: 295
Credit goes to @arieljuod
The issue was a CSS issue.
Inspecting the A element in dev tools resulted in the dev tools focusing on the HTML element, not the A element.
Looking at the CSS rules for a div element that was an ancestor of the A tag, I noticed a z-index of -2 and vaguely recalled z-index influencing the clickability of its descendant tags.
I was able to set The z-index to 0, then add a positive z-index to a different element entirely, and regained the functionality of the link.
Upvotes: 0