I'm writing some if/elsif statements to display error messages. When I leave the username blank and fill the other fields in correctly, it still goes to the else statement and displays "All fields must be completed." Can someone point out the error in my logic/syntax?
<% if @user.errors.any? %>
<div id="error_explanation" class="round">
<% if @user[:name].nil? and @user[:email].not.nil? and @user[:password].not.nil? and @user[:password_digest].not.nil? %>
<h2>Please enter a valid username. </h2>
<% else %> <!--If any field is left blank -->
<h2>All fields must be completed. </h2>
<% end %>
</div>
<% end %>
Let me know if you need anything else.