AlexNikolaev94
AlexNikolaev94

Reputation: 1209

Set a page title in rails

I'm writing a simple imageboard and I want the page titles, i.e. those between <title> tags, change corresponding to the board I'm actually visiting. E.g. I visit the /b/ board, and the page title becomes /b/ - MyChan. I thought to make it something like this:

<% unless current_page?(root_path) %>
    <title>
        <%= @board.title %> - MyChan
    </title>
<% else %>
    <title>MyChan</title>
<% end %>

but I'm not sure if that will work

Upvotes: 0

Views: 231

Answers (1)

AlexNikolaev94
AlexNikolaev94

Reputation: 1209

So, the answer already was in my question - the code I provided above,

<% unless current_page?(root_path) %>
    <title>
        <%= @board.title %> - MyChan
    </title>
<% else %>
    <title>MyChan</title>
<% end %>

works exactly as I need

Upvotes: 1

Related Questions