In my Rails 4 app, there is a Post model, with both a :copy and a :short_copy attribute.
In the Posts#Show view, I want to display the :short_copy if it was defined by the user, and the :copy otherwise.
So, I implemented the following code:
<% if @post.short_copy %>
<%= @post.short_copy %>
<% else %>
<%= @post.copy %>
<% end %>
Problem: when the :short_copy is defined, it does show up, however, when it is not defined (and a :copy is defined), the :copy does not show up.
Is there something wrong with this code?
Aucun commentaire:
Enregistrer un commentaire