0

How to use link tag in ruby on rails?

<%  link_to "Stephen Weber", "home.html" %>   
vee
  • 38,255
  • 7
  • 74
  • 78
user3279260
  • 73
  • 1
  • 2
  • 8

3 Answers3

1

You have missed =, its should be <%=

<%=  link_to "Stephen Weber", "home.html" %>
Ishank Gupta
  • 1,575
  • 1
  • 14
  • 19
  • i didn't get the proper output.its say No route matches "/home.html" with {:method=>:get} what can i do?please help me.thank u for advance – user3279260 Feb 13 '14 at 11:54
0

It depends on the type of view renderer engine you are using, if you are using Haml-rails then syntax is slightly different, remember that Haml views are indentation based just like python :

= link_to "Stephen Weber", "Home.html", {class: 'any_class_name', id: 'try_to_use_unique', style: 'margin:'''}

If you are using erb, then syntax is:

 <%= link_to "Stephen Weber", "Home.html", {class: 'any_class_name', id: 'try_to_use_unique', style: 'margin:'''} %>
Sanjiv
  • 813
  • 6
  • 13
0

You have missed = in

<% link_to "Stephen Weber", "home.html" %>

It should be

<%= link_to "Stephen Weber", "home.html" %>

For more details on Rails ERB format, go to Why many people use "-%>" instead of "%>" in Rails?

Community
  • 1
  • 1
Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78