Skip to content

Instantly share code, notes, and snippets.

@esteedqueen
Forked from davidphasson/show.html.erb
Created June 6, 2016 11:55
Show Gist options
  • Save esteedqueen/6947239d0d160a7b499fce70a06c88e2 to your computer and use it in GitHub Desktop.
Save esteedqueen/6947239d0d160a7b499fce70a06c88e2 to your computer and use it in GitHub Desktop.
ERB and the case statement
# Doesn't work
<p>
<% case @request.author_hosted %>
<% when "yes" %>
The school <b>has</b> hosted an author before.
<% when "no" %>
The school <b>has not</b> hosted an author before.
<% end %>
</p>
# Does
<p>
<% case @request.author_hosted
when "yes" %>
The school <b>has</b> hosted an author before.
<% when "no" %>
The school <b>has not</b> hosted an author before.
<% end %>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment