I have a model that has an icon associated to it. This icon upload is managed by Carrierwave.
My issue arises when I try to send the file via ajax from my form.
My Model is as follows:
class Category < ActiveRecord::Base
attr_accessible :name,
:icon
mount_uploader :icon, TemplateCategoryIconUploader
end
Controller action:
def update
@category = Category.find(params[:id])
@category.update_attributes(params[:category])
if @category.save
flash[:notice] = "Category Updated!"
render_ajax_content_replace :element => :show_category, :partial => 'show'
else
render_ajax_content_replace :element => :show_category, :partial => 'show'
end
end
And finally my form:
<%= form_for @category, :html => {:multipart => true}, :remote => true do |f| %>
<%= error_messages_for f.object %>
<%= f.file_field :icon %>
<% end %>
Removing the ajax side of thing allows the submit to work. However I require it to be done with AJAX.
The error I get is a missing template error. However all my partials exist and work. For some reason the render_ajax_content_replace breaks. Its simply supposed to replace an element with a partial. This works perfectly everywhere else. Adding AJAX files breaks it.