I'm sure you're saving the uploaded file in any way (carrierwave, paperclip etc.).
So you know whether you already have an avatar or not.
If you have one, show the file name or even a thumb, if not, show a note.
But you cannot avoid the "No file selected" message because it (aka the browser) sais:
There is no file selected to upload with this POST.
You will end up with somthing like:
<%- if f.object.avatar.present %>
Known Avatar: <%= image_tag f.object.avatar.url(:thumb) %>
<%- else %>
no Avatar uploaded yet
<%- end %>
<%= f.file_field :avatar %>
Remark:
I used a thumb url generating syntax of carrierwave. It may vary with other attachment gems.
I don't know your form object, that's why I used the f.object
. If it's i.e. @user
, you can simplify it:
<%- if @user.avatar.present %>
Known Avatar: <%= image_tag @user.avatar.url(:thumb) %>
<%- else %>
no Avatar uploaded yet
<%- end %>
<%= f.file_field :avatar %>