samedi 31 mars 2018

Syntax for conditions(if/else) when "views" should be set as a condition in RoR?

My navigationbar is underneath the header... I want to change the header according to the view on which the visitor is on.

What is the syntax for a condition(if/else) when views are set as condition in ruby on rails?

Something like...

<% if index.html.erb %>
  <%= image_tag("index_background.jpg", alt: "index background") %>
<% elsif about.html.erb %>
  <%= image_tag("about_background.jpg", alt: "index background") %>
<% else %>
  <%= image_tag("default_background.jpg", alt: "index background") %>
<% end %>

If you have any question don't hesitate to ask! Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire