I'm trying to change the following Rails link into primary color (it's currently white):
<%= link_to 'Edit' %>
I'm trying to change the following Rails link into primary color (it's currently white):
<%= link_to 'Edit' %>
You can add a class
to your link after providing the path.
<%= link_to 'Edit', edit_path, class: "a-primary" %>
And add styles for that class.
.a-primary{
/* styles for link */
}
If your application has a common style, there's no need to define a CSS class. Just write the CSS for <a>
tags in general:
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
Ruby code
<%= link_to 'Edit' , '#'%>
Rails renders the link_to script as a normal hyperlink in HTML.
<a href="#" > Edit</a>
then the browser will apply the style to all hyperlinks in the app.