Luca Milan
Luca Milan

Reputation: 125

How to create a link without href attribute on rails 3 with link_to?

i'm not able to create a link without the href attribute with link_to

<a class="some-class" title="some-title"></a>

i was searching in some documentation but i haven't seen anything related to this problem.

FYI this type of link is provided to have a clickable item with the title attribute and without the classic '#' in the url. i'm open to other solutions to the problem.

Any suggestion?

Upvotes: 2

Views: 2219

Answers (3)

Ch4rAss
Ch4rAss

Reputation: 754

Each link should have href attribute. You could set href to # like this:

<%= link_to "#", class: "some-class", title: "some-title" do %>
  Whatever
<% end %>

Upvotes: 1

kramsee
kramsee

Reputation: 309

You should check out the Tag Helper.

This should do the trick:

<%= tag "a", :class => "some_class", :title => "some_title"%>

Upvotes: 2

SoWhat
SoWhat

Reputation: 5622

you can just type it directly in the view

<a class="some-class" title="some-title"></a>

the link_to helper is used to get the baseurl

Upvotes: 1

Related Questions