Rails beginner
Rails beginner

Reputation: 14504

Rails layout show only html on mainpage

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

Upvotes: 0

Views: 273

Answers (1)

Gazler
Gazler

Reputation: 84140

<% 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 %>

Upvotes: 2

Related Questions