Created
July 31, 2014 15:23
-
-
Save markottaviani/faae2d0ab9e80b99bc80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_column :users, :has_own_cats | |
#Our radio button to fill out the answer in new or edit views | |
<div class="control-group"> | |
<%= f.label :has_own_cats, "Do you have your own cats?", :class => "control-label" %> | |
<div class="controls"> | |
<label> | |
<%= f.radio_button :has_own_cats, true, :class => "link required" %> | |
<span>Yes</span> | |
</label> | |
<label> | |
<%= f.radio_button :has_own_cats, false, :class => "link required" %> | |
<span>No</span> | |
</label> | |
</div> | |
</div> | |
# Then we have a render on the show page for the user. For the render I'd like one of these two messages to show up depending on TRUE or FALSE (as seen below). | |
# However, I also want to support with nil, and have nothing rendered to the screen if the user hasn't answered the question yet. Maybe some "unless" in here? | |
<% if @user.has_own_cats? %> | |
<p><span class="label label-important">Has own cats</span></p> | |
<% else %> | |
<p><span class="label label-success">Doesn't have own cats</span></p> | |
<% end %> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment