marcamillion
marcamillion

Reputation: 33775

How do I produce <a href="/" id="logo"> with the link_to helper?

All I want to produce is this HTML tag:

<a href="/" id="logo"></a>

I tried:

<%= link_to root_path, id: "logo" %>

But this produces:

<a href="/?id=logo">/</a>

I also tried:

<%= link_to(root_path), id: "logo" %>

But that produces:

SyntaxError at /
syntax error, unexpected ',', expecting ')'

Thoughts?

Edit 1

The reason I am doing it like this is because I am including the logo via CSS....so that's why I haven't done a link_to ... do block.

Upvotes: 0

Views: 838

Answers (2)

t56k
t56k

Reputation: 7001

Wouldn't it be:

<%= link_to '', root_path, :id => "logo" %>

Upvotes: 1

AdamT
AdamT

Reputation: 6485

This works for me:

<%= link_to "linky", "/", id: "logo" %>

If you don't want there to be a value you can just omit "linky" but leave the string declaration like:

<%= link_to "", "/", id: "logo" %>

This returns

<a id="logo" href="/">linky</a>

Upvotes: 2

Related Questions