vendredi 25 mars 2016

Syntax of IF statement Rails 4 with Asset Pipeline

I am trying to check if an image file exists in the asset pipeline and if it not there display a default. If it is there I want to display it instead. Where am I going wrong?

<% if "#{@person.user_name}.jpg".nil %>
  <%= image_tag("default.gif") %>
<% else %>
  <%= image_tag("#{@person.user_name}.jpg") %>
<% end %>

Aucun commentaire:

Enregistrer un commentaire