Frage

Using Refinery CMS to create product pages in our prototype. An admin can add a link to the main product page, and it will display similar to

Product Links
www.example.com/product/1
www.example.com/product/2

here is a screenshot of how it currently is being displayed

when product link is added

However, there will not always be a case when the ink is added. And this looks weird to have that field but no links in there because every element has margin-bottom:30px;

When no link is added

So my question is how do I make the element not show up at all if nothing is passed to it. Here is the code for the element:

HTML

<div class="contentPageElement">
  <h3>Product Links</h3>
  <%= link_to @discussion.link.to_s, @discussion.link %>
</div>
War es hilfreich?

Lösung

you can either put it in helper,or do something like this.

<% unless @discussion.link.empty? %>
<div class="contentPageElement">
  <h3>Product Links</h3>
  <%= link_to @discussion.link.to_s, @discussion.link %>
</div>
<% end %>

Andere Tipps

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top