1

I have a link tag of rails like below

<%= link_to 'New Product', new_product_path %>

I want to increase the font size of the New Product and apply some CSS property to it.

Can I do that in the rails tag itself?

Suraj
  • 2,423
  • 12
  • 39
  • 75
  • Yes, you can as said in the above link. But I will still use a class instead of inline styling. – m4n0 Dec 08 '15 at 09:12

1 Answers1

2
<%= link_to 'New Product', new_product_path, {style: 'font-size: 2em;  color: black' } %>

But a nicer solution would be, to add a class to the link, and than style the class in a separate css-file.

<%= link_to 'New Product', new_product_path, class: 'myclass'  %>

CSS-File:

.myclass {
    font-size: 2em;
    color: black;
}
Michael B
  • 1,660
  • 3
  • 28
  • 59
  • `<%= link_to 'New Expense', new_expense_path {style: 'font-size: 2em; color: black' } %> ` I get syntax error for some reason syntax error, unexpected ':', expecting '}' – Suraj Dec 08 '15 at 09:16
  • 2
    okay, I was missing the comma. my bad And yes I am using the secodn method – Suraj Dec 08 '15 at 09:17