0

I want to show some HTML in my layout only on the mainpage.

The code in layout:

<% if current_url = root_path %>
Sometxt
<% end %>

But it is appearing not only on the mainpage but also /example

Rails beginner
  • 14,321
  • 35
  • 137
  • 257

1 Answers1

2
<% if current_url = root_path %>

This will always return true as it is an assignment. You need a double equals.

<% if current_url == root_path %>

current_url is not a method either, you want to use request.path.

<% if request.path == root_path %>
Gazler
  • 83,029
  • 18
  • 279
  • 245