Skip to content

Instantly share code, notes, and snippets.

@ctcherry
Created November 7, 2008 23:19
Show Gist options
  • Save ctcherry/22993 to your computer and use it in GitHub Desktop.
Save ctcherry/22993 to your computer and use it in GitHub Desktop.
*if block:*
Pretty straightforward.
<% if @property.floorplans.size == 1 %>
<div>Show This if the property only has 1 floorplan</div>
<% else %>
<div>Show This if the property has any other number of floorplans</div>
<% end %>
*unless block:*
unless is the opposite of an if. You can think of it as being an "if not" if that helps at all. Also I generally try to avoid unless + else because it can be a little bit hard to understand at first glance.
<% unless @property.floorplans.size == 1 %>
<div>Show This if the property has any other number of floorplans</div>
<% else %>
<div>Show This if the property only has 1 floorplan</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment