Rails - set default value for form text_field with current_user
Its not showing because the if statement applies to the whole text-field, not just the value attribute. This will work:
<% if current_user %>
<%= f.text_field :email, required: true, class: 'form-control', value:current_user.email %>
<% else %>
<%= f.text_field :email, required: true, class: 'form-control'%>
<% end %>
However, if you are using devise, it comoes with a helper method that is generally better to user than current_user. I think your code should be this:
<% if user_signed_in? %>
<%= f.text_field :email, required: true, class: 'form-control', value:current_user.email %>
<% else %>
<%= f.text_field :email, required: true, class: 'form-control'%>
<% end %>
http://apidock.com/rails/Object/try
<%= f.text_field :email, required: true, class: 'form-control', value: current_user.try(:email) %>