i am working on rails with paperclip gem and trying to upload a document ,
this is my html form
<div style="background: #ee6e73; width: 100%;"><h3 class="center-align" style="color: #fff;font-weight: 600 !important;">Upload Resume</h3></div>
<div class="modal-content">
<%= form_for(Document.new, :url => resume_upload_individual_profile_path, remote: true, :html => {:multipart => true } ) do |f| %>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<%= hidden_field_tag :profile_id, @profile.id %>
<div class="row">
<div class="file-field input-field">
<div class="btn">
<span>Choose Document</span>
<i class="material-icons prefix">input</i>
<%= file_field_tag :document %>
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" style="float: left;margin-top: 0%;" class="waves-effect waves-light btn-large "><i class="material-icons left">cloud</i>Submit</button>
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Close</a>
</div>
<% end %>
and my controller action is
def resume_upload
p params
@resume = Document.create(resume_params)
if @resume.save
@message = 'Your Resume has been successfully uploaded'
# redirect_to individual_profile_path(individual_id: current_individual.id)
else
# redirect_to individual_profile_path(individual_id: current_individual.id)
@message = find_error(@resume)
end
respond_to do |format|
format.js
end
end
and my model has
has_attached_file :document
validates_presence_of :document
validates_attachment_content_type :document, :content_type => ["application/pdf","application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"text/plain"]
the issue i am facing is when i select a file and try to uplaod , i get an error ActionController::UnknownFormat
but I am not facing this issue when i submit the form without selecting the file , i am able to successfully go into the js.erb file.