I have the following written:
<% if @document != nil %>
<%= form_for(@document, :html => { :multipart => true }) do |f| %>
<% if @document.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@document.errors.count, "error") %> prohibited this document from being saved:</h2>
<ul>
<% @document.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<% if notice %>
<p id="notice"><%= notice %></p>
<% end %>
<%= render partial: 'documents/resume' %>
<div id="add_buttons">
<%= f.file_field :resume %>
<%= f.submit %>
</div>
<% end %>
<% else %>
<h1>No Document Available</h1>
<% end %>
Sorry about the indenting, copy/paste didn't paste it right. Anyways, this is using paperclip and works fine to upload a document as long as in the resume partial that I have listed I have my delete button commented out. Here is the code for that partial:
<div class='Resume_1'>
<%#= @current_user = session[:user] %>
<%#= @document = @current_user[:document] %>
Current Resume:
<%= render partial: 'documents/resumelink' %>
</div>
<div class='Resume_2'>
<% if (@document != nil) && (@document.resume_file_name != nil) %>
<%= button_to "Delete Resume", @document, method: :delete, data: { confirm: 'Are you sure you wish to delete your resume?' } %>
<% end %>
</div>
If the button_to line is commented out, the update document (f.submit) button works fine. However, if the button_to line is left in, the f.submit button does nothing. And here's the destroy function (which is where the delete method is routed to) since this doesn't actually seem to remove the resume either.
def destroy
@document.resume = nil
respond_to do |format|
format.html { redirect_to welcome_url, notice: 'Resume was successfully deleted.' }
format.json { head :no_content }
end
end
Thanks for any help.